0

Trying to write a powershell script to output the size of replication delta files in a Hyper-v environment, that will be run on a schedule, but when I run the following script the output file is populated with the following:

Microsoft.HyperV.PowerShell.VMReplicationHealth

script:

$csvfile = “.\VM_Status.csv”
$test = Measure-VMReplication  
Add-Content -Path $csvfile  -Value $test

How can I fix this? Output should be like this:

Name    State       Health   LReplTime             PReplSize(M) AvgLatency AvgReplSize(M) Relationship
----    -----       ------   ---------             ------------ ---------- -------------- ------------
MAIL   Replicating Normal   16/04/2018 8:53:09 AM 0.00         00:00:02   4.08           Simple      
APP    Replicating Normal   16/04/2018 8:53:43 AM 0.00         00:00:00   32.15          Simple      
UTM    Replicating Critical 11/04/2018 4:06:54 PM 0.00                    0.00           Simple
Chris
  • 23
  • 4
  • 1
    `Add-Content` is for basic text. If you want CSV style output use `Export-CSV` instead which better handles objects which is what you output is. – Matt Apr 16 '18 at 00:17
  • See https://stackoverflow.com/a/44246434/45375 – mklement0 Apr 16 '18 at 01:29

0 Answers0