My requirement is to - "Enable Guest Customization--> Poweron the VM --> wait till the customization is completed. --> Poweroff the VM --> Disable the Guest Customization "
$vmcontent =""
$vmhref = $vm.href+"/guestcustomizationstatus"
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$Headers.Add('x-vcloud-authorization', $sessionkey)
$Headers.Add('accept','application/*+xml;version=31.0')
$Headers.Add('Content-Type','application/xml')
[xml]$vmcontent = (Invoke-WebRequest -uri $vmhref -Method get -Headers $headers).content
Write-host -NoNewline 'Guest Customization in Progress...'
try{
while($vmcontent.GuestCustomizationStatusSection.GuestCustStatus -ne 'GC_COMPLETE')
{[xml]$vmcontent = (Invoke-WebRequest -uri $vmhref -Method get -Headers $headers).content
Write-Host -NoNewline '.'
Start-Sleep -Seconds 3}
}
catch{}
Write-host "Guest Customization Complete"
above can be used to get the Guest OS customization of a VM..
_____________________________________________________________________________
Was it helpful? Let us know by completing this short survey here.
You can wait for the CustomizationEvent to appear.
There are 2 possible extensions that you can watch for: CustomizationSucceeded and CustomizationFailed
The latter even has derived events that would show which broad class of failure occurred
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
$vmcontent =""
$vmhref = $vm.href+"/guestcustomizationstatus"
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$Headers.Add('x-vcloud-authorization', $sessionkey)
$Headers.Add('accept','application/*+xml;version=31.0')
$Headers.Add('Content-Type','application/xml')
[xml]$vmcontent = (Invoke-WebRequest -uri $vmhref -Method get -Headers $headers).content
Write-host -NoNewline 'Guest Customization in Progress...'
try{
while($vmcontent.GuestCustomizationStatusSection.GuestCustStatus -ne 'GC_COMPLETE')
{[xml]$vmcontent = (Invoke-WebRequest -uri $vmhref -Method get -Headers $headers).content
Write-Host -NoNewline '.'
Start-Sleep -Seconds 3}
}
catch{}
Write-host "Guest Customization Complete"
above can be used to get the Guest OS customization of a VM..
_____________________________________________________________________________
Was it helpful? Let us know by completing this short survey here.
That only works for VDC, which you didn't specify in your question.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks LucD, Sorry i thought i mentioned it.. Anyways, your comments have always been very informative..