Quantcast
Viewing all articles
Browse latest Browse all 201333

Re: VM Disk Stats output

Try something like this

 

$metrics="disk.numberwrite.summation"
$vms=Get-VM|where {$_.PowerState-eq"PoweredOn"}

$report=Get-Stat-Entity$vms-Stat$metrics-maxsamples1-IntervalSecs20|
Group-Object-PropertyEntityId|Foreach-Object{
 
$row=New-ObjectPSObject-Property@{
        
VM=$_.Group[0].Entity.Name
  }
 
$i=1
 
$_.Group|Group-Object-PropertyInstance|%{
   
$row|Add-Member-Name"Instance$i"-Value$_.Group[0].Instance-MemberTypeNoteProperty-PassThru|
   
Add-Member  -Name"Value$i"-Value$_.Group[0].Value-MemberTypeNoteProperty
   
$i++
  }
 
$row
}
$report|Sort-Object-Property {$_|Get-Member|Measure-Object|select-ExpandPropertyCount} -Descending|
Export-Csv"C:\report1.csv"-NoTypeInformation-UseCulture

 

It will add a property per instance.

At the end it needs to sort descending on the number of properties in a row.

This to avoid a problem with the Export-Csv cmdlet, that takes the first line to determine how many columns there are in the CSV


Viewing all articles
Browse latest Browse all 201333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>