Quick Tip!!
So I was asked to create a custom property that gives a quick overview of the total size for the virtual disks on a VM
So, leveraging of my DataStore script, I came up with the below..
Enjoy
Note: This assumes you have created your custom property already
$VMS = Get-scvirtualmachine Foreach ($VM in $VMS) { $DZ = $null $dzprop = Get-SCCustomProperty -Name Datasize $DataSize = Get-SCCustomPropertyValue -CustomProperty $dzprop -InputObject $VM IF ($DataSize.Value -eq $null) { $VHDS = Get-SCVirtualHardDisk -VM $VM $storage = 0 $DZ = 0 ForEach ($VHD in $VHDS) { $Storage += $VHD.Size } $storage = $storage/1GB $storage = [math]::Round($storage) $DZ = [string]$storage $DZ = $DZ + "GB" Write-Host -ForeGroundColor Green "Setting DataSize property for $VM to $DZ" Set-SCCustomPropertyValue -CustomProperty $dzprop -InputObject $VM -Value $DZ } ELSE { $DSV = $DataSize.Value Write-Host -ForegroundColor Yellow "DataConfig exists for $VM with value '$DSV'" } }