Hi,
We have the below PowerCLI script,
Get-VMResourceConfiguration -VM vm_name | Format-Custom -Property DiskResourceConfiguration | out-string -stream | select-string 'NumDIskShares | DiskLimitIOPerSecond'
which gets the below details from a VM.
A sample output would be,
for each disk.
So my question is, how to adjust the particular script in order to loop through all the VMs found in vCenter and print this info, including the name of each VM?
Thank you in advance.
If you're using PowerShell v4, you could do
Get-VM |
Get-VMResourceConfiguration -PipelineVariable vm | Select -ExpandProperty DiskResourceConfiguration |
Select @{N='VM';E={$vm.VM.Name}},Key,NumDiskShares,DiskLimitIOPerSecond
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
If you're using PowerShell v4, you could do
Get-VM |
Get-VMResourceConfiguration -PipelineVariable vm | Select -ExpandProperty DiskResourceConfiguration |
Select @{N='VM';E={$vm.VM.Name}},Key,NumDiskShares,DiskLimitIOPerSecond
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi,
Thank you for the prompt reply.
Your proposed snippet works perfectly and does exactly what I'm looking for, much appreciated. I went a step forward and added some conditions in case someone is interested in a similar solution.
# Get the NumDiskShares and DiskLimitIOPerSecond for all VMs in vCenter of which NumDiskShares is greater than X number and export the output in a .csv file
Get-VM | Get-VMResourceConfiguration -PipelineVariable vm | Select -ExpandProperty DiskResourceConfiguration | Select @{N='VM';E={$vm.VM.Name}},NumDiskShares,DiskLimitIOPerSecond | Where {$_.NumDiskShares -gt X} | Export-Csv -NoTypeInformation -UseCulture -Path C:\temp\output.csv
# Get the NumDiskShares and DiskLimitIOPerSecond for all VMs in vCenter of which NumDiskShares is greater than X number, filter VMs based on a Z string and export the output in a .csv file
Get-VM | Get-VMResourceConfiguration -PipelineVariable vm | Select -ExpandProperty DiskResourceConfiguration | Select @{N='VM';E={$vm.VM.Name}},NumDiskShares,DiskLimitIOPerSecond | Where {($_.NumDiskShares -gt X) -and ($_.vm -notlike '*Z*')} | Export-Csv -NoTypeInformation -UseCulture -Path C:\temp\output_rev.csv
Thanks again.
