Automation

 View Only
  • 1.  PowerCLI NumDiskShares and DiskLimitIOPerSecond per VM

    Posted Aug 11, 2016 01:45 PM

    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.



  • 2.  RE: PowerCLI NumDiskShares and DiskLimitIOPerSecond per VM
    Best Answer

    Posted Aug 11, 2016 04:02 PM

    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



  • 3.  RE: PowerCLI NumDiskShares and DiskLimitIOPerSecond per VM

    Posted Aug 12, 2016 07:26 AM

    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.