Azure AD Connect stopped syncing to Azure AD. Looking in Azure AD Connect Synchronization Service…
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.
Table of contents
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:
- In the beginning, a reply is showing because the computer is still connected.
- After a couple of seconds, we can’t see a reply. We see a request timed out because the computer is offline.
- 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.
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.