Thursday, May 23, 2013

How To Restart Computers Remotely via PowerShell



You can use the below cmdlet to restart your own computer :
PS C:\> Restart-Computer

To restart a remote computer remotely.
PS C:\> Restart-Computer Server01 -whatif
What if: Performing operation "Restart-Computer" on Target " (Server01)".
The -WhatIf parameter is used to verify the command.

You can use the below commands to reboot multiple computers.
PS C:\> restart-computer "server01","server02","server03" -whatif
PS C:\> restart-computer (get-content c:\work\computers.txt)

You can use below command to pass the credentials
PS C:\> restart-computer (get-content c:\work\computers.txt) -credential "mycompany\administrator"

The Restart-Computer cmdlet will fail, if a logon session is detected.Use the -force parameter to force a reboot.