Hello Everybody,
I want to use a script to reboot windows servers in order with a condition that to ensure that the last server rebooted is up before rebooting the next server.
I'm using a script for that, but it's rebooting all machines in the same time
Can you please help me about that
you'll find Below the used script :
echo offset sleep=300
set retrys=3
REM define order
For /F %%I in (c:\test\servers.txt) do (
call :Restart %%I
call :StatusCheck %%I
)
goto :eof
Rem Reboot the first box after 5 seconds and then sleeps for 5 minutes before checking the Netlogon service
:Restart
shutdown -m \\%1 -r -f -t 5
goto :eof
Rem check and get the status of the Netlogon service and pipe the result into a text file saved with the server name
:StatusCheck
for /l %%x in (1, 1, 3) do echo %x (
sleep %sleep%
SC.exe \\%1 Query netlogon > c:\Test\%1.log
Find /i "RUNNING" < c:\Test\%1.log
IF not "%ERRORLEVEL%"=="0" (
ECHO %1 is NOT Back online yet! >C:\Test\%1Offline_%date%_%time%.log
) else (
goto :eof
)
)
goto :eof