Hi, in a script i want to restart a server and wait until the server is up to run the next command.
I know that in POSH 3 i can use -wait but i need to use POSH 2
What is the best way?
Restart-Computer -ComputerName $svr -AsJob
Thanks
Technology Tips and News
Hi, in a script i want to restart a server and wait until the server is up to run the next command.
I know that in POSH 3 i can use -wait but i need to use POSH 2
What is the best way?
Restart-Computer -ComputerName $svr -AsJob
Thanks
do a test-connection $srv this will tell you when pc is pinging from there run your command..
if(test-connection $svr){ your next step {
Hi,
I thought about that, but that will get me true or false..
If it is false will it keep doing it until it gets true and then move on?
Hi,
Take a look at this thread, it has several snippets that will help you:
You could do a endless loop until the server is up again
The only issue I see is, you can get a successful ping, even if the server isn't fully up, and still booting. So depending on your next tasks, they may or may not run correRestart-Computer $server
Do { Sleep 10 # Sleep for 10 secs, then test ping }While (Test-Connection $server)
You could do a endless loop until the server is up again
The only issue I see is, you can get a successful ping, even if the server isn't fully up, and still booting. So depending on your next tasks, they may or may not run correRestart-Computer $server
Do { Sleep 10 # Sleep for 10 secs, then test ping }While (!(Test-Connection $server))