VMware Cloud Community
NikhilPathak
Enthusiast
Enthusiast
Jump to solution

Do we have any way to identify that the Guest OS Customization is completed ?

My requirement is to - "Enable Guest Customization--> Poweron the VM --> wait till the customization is completed. --> Poweroff the VM --> Disable the Guest Customization "

Reply
0 Kudos
1 Solution

Accepted Solutions
NikhilPathak
Enthusiast
Enthusiast
Jump to solution

$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.

View solution in original post

Reply
0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
NikhilPathak
Enthusiast
Enthusiast
Jump to solution

$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.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

That only works for VDC, which you didn't specify in your question.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
NikhilPathak
Enthusiast
Enthusiast
Jump to solution

Thanks LucD, Sorry i thought i mentioned it.. Anyways, your comments have always been very informative..

Reply
0 Kudos