vin01
Expert
Expert

Thanks Its working. I used as below as scripttext in invoke-vmscript.

$updateObject = New-Object -ComObject Microsoft.Update.Session

$updateSearcher = $updateObject.CreateUpdateSearcher()

$searchResults = $updateSearcher.Search("IsInstalled=0")

$timeoutValue = 1200

$startTime = Get-Date

while($searchResults.Updates.Count -ne '0' -and (New-TimeSpan -Start $startTime -End (Get-Date)).TotalSeconds -lt $timeoutValue){

Start-Sleep 1

$searchResults.Updates.Count

}

if((New-TimeSpan -Start $startTime -End (Get-Date)).TotalSeconds -ge $timeoutValue) {

'windows update completed Partially'

}

else{

'windows update completed sucessfully'

}

Regards Vineeth.K
Reply
0 Kudos