Windows computers can be restarted from command line remotely. We can Use the
shutdown MS-DOS command or
Restart-Computer Powershell command in order to restart computers remotely. The shutdown command can be used to restart remotely via the PowerShell.
Restart Using shutdown Command
shutdown command can be used to restart Windows compuer remotely. The
/r option is specified to restart and the remote system name or IP address is also provided. The remote system does not restart immmediately. About after 1 minute the remote system is restarted.
> shutdown /r /m \\db1
In the following example we use the remote windows computer IP address.
> shutdown /r /m \\192.168.1.10
Restart Providing Message
During restart of the remote windows system we can provide some message or information to the remote windows system users. The
/c option is used to specify the message. The message is provided between double quotos.
> shutdown /r /m \\db1 /c "This Windows System Is Restarted for Update Purposes"
By default the shutdown command restart remote windows system after 1 minute. But we can restart the remote system immediately by usin the
/t 0 option. The
/t option is used to specify the timeout for restart and we provide 0 to restart immediately.
> shutdown /r /m \\db1 /t 0
Log Off Users
A windows system which can be a Windows Server may be used multiple users at the same time. We can use the shutdown command in order to log off users from the remote system without restarting.
> shutdown /l /m \\db1
Restart Using PowerShell
PowerShell provides the
Restart-Computer command or commandlet in order to restart remote Windows computers. The Restart-Computer command provides different options and features to restart remote windows system.
-ComputerName is used to specify the remote computer with its hostname or IP address. The
-Force option is used to force restart where some application or services may prevent it accidentally.
PS> Restart-Computer -ComputerName 192.168.1.10 -Force
Shutdown Using PowerShell
We can shutdown or stop remote Windows computer with the
Stop-Computer PowerShell command.
PS> Stop-Computer -ComputerNAme 192.168.1.10 -Force
Restart Multiple Computers
We can restart multiple computers with the
Restart-Computer PowerShell command. The computer names or IP addresses can be stored in a text file line by line. The text file can read with the
Get-Content command and redirected into the Restart-Computer command.
192.168.1.10 db1 server1.windowstect.com
PS> Restart-Computer (Get-Content C:\Users\ismail\computers.txt)