I have around 30VMs under a Folder, for which I need to increase Harddisk1 by 20GB, can someone provide me a script to accomplish same.
I assume, since you mention Harddisk1, that this VMDK holds the system partition ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes LucD, they windows 2k8 Servers..I am trying to increase system partition by 20GB.
If the VMs have a supported OS, you can do something like this
$folderName = "MyFolder"
$helperName = "MyHelperVM"
$extraGB = 20
$helperVM = Get-VM -Name $helperName
if($helperVM.PowerState -ne "PoweredOff"){
"The HelperVM needs to be powered off !"
return
}
Get-Folder -Name $folderName | Get-VM | %{
if($_.PowerState -eq "PoweredOff"){
$hd = Get-HardDisk -VM $_ | where {$_.Name -eq "Hard disk 1"} |
Set-HardDisk -HardDisk $hd -CapacityGB ($hd.CapacityGB + $extraGB) -HelperVM $helperVM -ResizeGuestPartition
}
else{
"VM $($vm.Name) is not powerd off"
}
}
It's possible that you need to provide credentials for the guest OS on the Set-Harddisk cmdlet
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks its working fine..