Is it safe to assume Server can execute commands on successful ping after restart?

by Balthazar   Last Updated November 16, 2018 20:01 PM

I'm creating a script that remotely restarts several servers, then waits for them to be online again, and run some startup commands on them after they successfully restarted.

Two questions are in my mind about that:

  • Is it safe to assume that a Server can process commands like invoke-command, start-scheduledtask, start-service, start-process after a successfull ping from a remote machine?

  • Does the user being logged in or not influence the successfull invocation of the startup commands mentioned in the first question?

Here's the code I use to wait for my servers:

$Waiting = $false
while ($Waiting -contains $false)
    $Waiting = @()
    foreach($Var in $AllVars)
        $Computer = $Var.Value.Computer
        $Ping = Test-Connection $Computer -Count 1 -Quiet
        $Waiting += $Ping

All of my Servers are on Windows Server 2012 R2 and above

Related Questions

SCCM 2012 Retains Old IP Address of Offline Client

Updated March 02, 2017 05:01 AM