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

2 Comments

  1. Mark Robinson

    What syntax would you add to export the results of this report to a CSV file? Scripting is not my strong suit.

    Thanks in advance,

    Mark

  2. Daniel Cote

    From my results it list raw device mapped drive non the dsk mode set to independant disk (persistent or nonpersistent) is that normal? Also how would I ran a report to list the dependent disk?

Leave a Comment

Your e-mail address will not be published. Required fields are marked *