LucD
Leadership
Leadership

Instead of doing a try-catch, you could test in a loop, eventually with a timeout to avoid an endless loop, if the GuestOperationsReady property in the GuestInfo object returns $true.
A simple example, without a timeout.

while (-not $vm.ExtensionData.Guest.GuestOperationsReady)
    {
      Start-Sleep 2
      $vm.ExtensionData.UpdateViewData('Guest')
    }

 


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