PowerShell is a powerful tool for managing Windows systems, and one of its many capabilities is remotely restarting Windows Servers. This feature is invaluable for administrators managing multiple servers in different locations. Here’s a concise guide on how to execute a remote restart and troubleshoot common issues.
Setting Up for Remote Restart
To restart a remote Windows Server, ensure the target machine is configured for remote management. PowerShell relies on Windows Remote Management (WinRM) for remote operations. You can enable it on the target server by running:
Enable-PSRemoting -ForcePowerShellAdditionally, check that the Windows Firewall allows traffic on ports 5985 (HTTP) and 5986 (HTTPS), which are required for WinRM. If needed, adjust the firewall settings:
Set-NetFirewallRule -Name WINRM-HTTP-In-TCP-Public -RemoteAddress Any
Set-NetFirewallRule -Name WINRM-HTTP-In-TCP-Private -RemoteAddress AnyPowerShellRestarting the Remote Server
Once the setup is complete, you can restart the remote server using the Restart-Computer cmdlet:
Restart-Computer -ComputerName "Server HostName / IP Address" -Force -Credential $credentialPowerShell-ComputerNamespecifies the server, and-Credentialprompts for the username and password of an account with administrative privileges on the target machine.- Without
-Force: The system waits for all applications and services to close gracefully, which may cause delays. - With
-Force: The restart happens immediately, ignoring unsaved work or unresponsive applications.
PowerShell’s remote restart capabilities simplify server management, saving time and effort. By properly configuring WinRM, ensuring firewall rules, and providing correct credentials, administrators can efficiently restart servers remotely. This approach enhances operational efficiency, particularly in environments with numerous servers.

Leave a Reply