This might take you < 1 minute to read.

I wanted to be able to search for a VM and get the free space on the LUN used for that VM. I put out some other data as well…

Param(
[Parameter(Mandatory=$true)]
[string]$servername
)
$vmmserver = "nameofvmmserver"

[System.Collections.ArrayList]$VMDisks = @()
foreach ($server in (Get-SCVirtualMachine -VMMServer $vmmserver | where {$_.name -match $servername})) {
$hostcluster = 
foreach ($disk in $server.VirtualHardDisks) {
$object = New-Object –TypeName PSObject -Property (
@{'servername'=$server.name;
'hostcluster'=(Get-SCVMHost $server.HostName).HostCluster.Name;
'volumename'=$disk.hostvolume.name;
'vmdisk'=$disk.name;
'volumelabel'=$disk.hostvolume.VolumeLabel;
'capacity'=([math]::truncate($disk.HostVolume.Capacity/ 1GB)), "GB"-join " ";
'freespace'= ([math]::truncate($disk.HostVolume.FreeSpace/ 1GB)), "GB"-join " ";
'diskname'=$disk.HostVolume.StorageDisk.ClusterDisk.Name;
'diskowner'=$disk.HostVolume.StorageDisk.ClusterDisk.ownernode;
})
$VMDisks.add($object)
}
}
$VMDisks| Sort-Object servername