Code snippet – Report VMs with independent discs

This script will report all VMs with a connected independent disc:

Just fill in the name of your vCenter Server name in the first line:


Connect-VIServer vcenter_server
$report = @()
Get-VM | where {$_ | Get-HardDisk | where {$_.Persistence -like "Independent*"}} | %{
     $row = "" | Select VMname, HDname
     $row.VMname = $_.Name
     $row.HDname = ($_ | Get-HardDisk | where {$_.Persistence -like "Independent*"}).Name
     $report += $row
} 
$report

Leave a Comment

Your email address will not be published. Required fields are marked *