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

WIMMount (HSM) causing cluster storage to go redirected (2012r2 DC)

Failed to delete the test record dcdiag-test-record in zone test.com

Azure MFA with Azure AD and RDS