Hello Guys,
I am trying to do a script to take all the VMs from a specific CSV (Cluster Shared Volme) and the VHD attached to them.
My script look like:
Get-SCVirtualMachine -VMMServer VMMServerName -all | where{$_.location -like ‘C:\ClusterStorage\VolumeX’} | Select-Object Name,Location, @{N="Capacity(GB)";E={[math]::Round($_.TotalSize/ 1GB)}}The output is good but the only problem is with the VMs that have more the 1 VHD disk. I have VMs with multiple VHD disks on multimple CSV LUNs.
EX: VM x has a disk on CSV1 and a disk on CSV2 and i need to get only the disk size from CSV1. In my script I get object TotalSize and because of that i get a sum of the 2 disks.
I did some research on google and i found the command Get-VHD and i have modify my script like this:
$VMs= Get-SCVirtualMachine -VMMServer VMMServerName -all | where{$_.location -like ‘C:\ClusterStorage\VolumeX’}
foreach ($VM in $VMs) {
Get-VHD | Select-Object Name,Location, @{N="Capacity(GB)";E={[math]::Round($_.TotalSize/ 1GB)}}
}But when i run it i get the message: Path[0]:
What i am doing wrong?
Thanks!