Hot Modify disks in vCloud Director using PowerCLI

I did not write this script, I found it on this excellent blog, I had a few problems getting the original code to work so thought I would share what I used to get this working. The script below increases the disk size to 70GB on a powered on VM.


Connect-CIServer vcloud.site.com -User administrator -Password password 

#Get VM called diskresize
$vm = Get-CIVM diskresize

#Define new size in MB
$newsize = "70240" 

#Modify the extension data with the new size
(($vm.ExtensionData.Section|where {$_-is  [VMware.VimAutomation.Cloud.Views.OvfVirtualHardwareSection]}).item|where {$_.ResourceType.value-eq17}).hostresource[0].AnyAttr[0]."#text" = $newsize

# Final step, update server data
($vm.ExtensionData.Section|where {$_-is[VMware.VimAutomation.Cloud.Views.OvfVirtualHardwareSection]}).updateserverdata()

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s