Restar-computer wait for next command


hi, in script want restart  a server , wait until server run next command.

i know in posh 3 can use -wait need use posh 2

what best way? 

restart-computer  -computername $svr  -asjob

thanks

you a endless loop until server again

restart-computer $server

do { sleep 10 # sleep 10 secs, test ping }while (!(test-connection $server))

issue see is, can successful ping, if server isn't up, , still booting. depending on next tasks, may or may not run correctly.

if find post has answered question, please mark answer. if find post helpful in anyway, please click vote helpful.

don't retire technet





Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Azure MFA with Azure AD and RDS

Failed to setup initiator portal. Error status is given in the dump data.

Invalid pointer on gpresult /h gpreport.html