Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 231085

Re: Wait until host goes offline and then execute a command

$
0
0

Would something like this do the trick ?

 

$count=0

$maxWait=10

 

Do {

  $count+=1

  Write-Output"$(get-date-fHH:mm:ss)$(get-date-fdd/MM/yyyy) - Host is online"

  sleep5

} While ((Test-Connection192.168.110.85-BufferSize16-Count1-Quiet) -or ($count-gt$maxWait))

 

if($count-gt$maxWait){

    Write-Output"Host still online"

}

else{

    Write-Output"$(get-date-fHH:mm:ss)$(get-date-fdd/MM/yyyy) - Host is offline"

}


Viewing all articles
Browse latest Browse all 231085

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>