VMware Cloud Community
flaxseed
Contributor
Contributor
Jump to solution

PowerCLI NumDiskShares and DiskLimitIOPerSecond per VM

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.

Capture.PNG

A sample output would be,

Capture1.PNG

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.

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

View solution in original post

Reply
0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
flaxseed
Contributor
Contributor
Jump to solution

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.

Reply
0 Kudos