
+ FullyQualifiedErrorId : Client20_VirtualDeviceServiceImpl_TryValidateHardDiskNewSize_InvalidSize. + CategoryInfo : InvalidArgument: (:), InvalidArgument first 1 | Set-HardDisk -CapacityGB (($vm.Disks.Capacity + $space. Set-HardDisk : 2:14:22 PM Set-HardDisk The specified size '78219344' is less than actual size of the virtual disk '79205464'. I choose "Yes to all" and then I get the following error. Additionally, when I run the script against other drives I get the following (see screenshot) before it actually runs it. The script below does not set the VM disk to a flat GB size, instead it sets it to 75.53621673583984. While I'm not entirely new to PowerShell, I still have a lot to learn. Get-HardDisk $vm.Vm | Select -first 1 | Set-HardDisk -CapacityGB (($vm.Disks.Capacity + $space - $vm.Disks.FreeSpace) / (1024 * 1024 * 1024))

So I only need 6GB extended in the hard drive.
#Vmguest raw disk map free
The VM hard drive is 70GB and has 24GB free space. While requesting help elsewhere, a script was provided to accomplish what I am requesting, but no explanation was given as to how this works nor explains the mathematics. I need this to work for 1500 VM's so it will can be automated to resize 30 VM's at a time. I need help with a script to check if the free disk space is 30GB and if it is less than 30GB, increase it to just the difference to make the free space 30.
