You're only running the update-code once. The while loop only runs the sleep command and write-host
(which will never change).. try this:
Connect-VIServer $vmserver -User $vmuser -Password $vmpass
do {
#This will min. once, until $status is 'toolsOK'
$status1 = (Get-VM -Name $vmname).Extensiondata.Summary.Guest.ToolsStatus
if($status1 -ne 'toolsOK') {
Write-Host "tool status is:" $status
Start-Sleep -Seconds 5
}
}
until($status1 -eq 'toolsOK')
Write-Host "success"
or
Connect-VIServer $vmserver -User $vmuser -Password $vmpass
$status1 = (Get-VM -Name $vmname).Extensiondata.Summary.Guest.ToolsStatus
while ($status1 -ne 'toolsOK') {
Write-Host "tool status is:" $status
Start-Sleep -Seconds 5
$status1 = (Get-VM -Name $vmname).Extensiondata.Summary.Guest.ToolsStatus
}
Write-Host "success"