Skip to content

Restart remote computer with PowerShell

Why do we need to restart a remote computer with PowerShell? We had to test new software, and the computer stopped responding after clicking the File Explorer. The problem is that we could not end any tasks. The computer is hours away from us, and nobody was in the area. What is the best solution? The best approach is to restart the computer remotely. In this article, you will learn how to restart a remote computer with PowerShell.

Restart remote computer with PowerShell

Run PowerShell as administrator. We are going to make use of the Restart-Computer cmdlet. The computer’s name is PC01.

PS C:\> Restart-Computer -ComputerName "PC01"
Restart-Computer : Failed to restart the computer PC01 with the following error message: The system shutdown can
not be initiated because there are other users logged on to the computer.
At line:1 char:1
+ Restart-Computer -ComputerName PC01
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (PC01:String) [Restart-Computer], InvalidOperationException
    + FullyQualifiedErrorId : RestartcomputerFailed,Microsoft.PowerShell.Commands.RestartComputerCommand

That didn’t work. Why is that?

There are users logged in on the computer, and we can’t restart the remote computer. If there are no users logged in, a restart will immediately start without fail.

Restart remote computer with PowerShell Force

We have to use the -Force parameter to restart the computer. Doing that will immediately restart the computer without a countdown.

PS C:\> Restart-Computer -ComputerName "PC01" -Force

The computer is restarting.

Ping remote computer

After running the above cmdlet, ping the computer. It will show us if we can reach the computer.

PS C:\> ping PC01 -t

Reply from 192.168.1.100: bytes=32 time=9ms TTL=120
Reply from 192.168.1.100: bytes=32 time=9ms TTL=120
Reply from 192.168.1.100: bytes=32 time=10ms TTL=120
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Reply from 192.168.1.100: bytes=32 time=9ms TTL=120
Reply from 192.168.1.100: bytes=32 time=9ms TTL=120

The ping is showing a reply, request timed out, and reply of the remote computer:

  1. In the beginning, a reply is showing because the computer is still connected.
  2. After a couple of seconds, we can’t see a reply. We see a request timed out because the computer is offline.
  3. The computer is starting again, and a reply is showing.

The computer is back online, and we can access the computer with remote desktop.

It’s good to know how to restart computers remotely. The next time you want to restart a computer, make sure to use PowerShell. I hope that this article helped you.

Read more: Exchange setup can’t continue PowerShell has open files »

Conclusion

In this article, you learned how to restart remote computer with PowerShell. Run the Restart-Computer cmdlet as shown to restart the remote computer. You can always check if the computer is going offline and starting again by pinging the computer.

Did you like this article? If so, you may also like to read Enable Windows Firewall with PowerShell. Follow us on Twitter and LinkedIn to stay up to date with the latest articles.

ALI TAJRAN

ALI TAJRAN

ALI TAJRAN is a passionate IT Architect, IT Consultant, and Microsoft Certified Trainer. He started Information Technology at a very young age, and his goal is to teach and inspire others. Read more »

This Post Has One Comment

  1. You can reboot the remote computer in the following way, with credentials from powershell:

    Restart-Computer -ComputerName -Force –user

    Ex:

    Restart-Computer -ComputerName tests -Force –user

    (it will ask you to enter the administrator credentials of the team in question)

Leave a Reply

Your email address will not be published. Required fields are marked *