Once an a while I need to list all my vmdk’s and what datastore they are on… So I created this script with output to CSV:
$outputFile = "D:\tmp\output.csv" $VMsAdv = Get-VM | Sort-Object Name | % { Get-View $_.ID } $myCol = @() ForEach ($VMAdv in $VMsAdv) { ForEach ($Disk in $VMAdv.Layout.Disk) { $myObj = "" | Select-Object Name, Disk $myObj.Name = $VMAdv.Name $myObj.Disk = $Disk.DiskFile[0] $myCol += $myObj } } $myCol | Export-Csv $outputFile -NoTypeInformation