Restart Computer - PowerShell


The Restart-Computer command in PowerShell is used to restart a local or remote computer. It is commonly employed to apply system updates or resolve software or hardware issues by rebooting the machine. This command can be executed on both local and remote computers, making it useful for managing multiple systems or performing remote troubleshooting.


Restart-Computer [-ComputerName] <ComputerName> [-Credential <PSCredential>] [-Force] [-WhatIf] [-Confirm] [-AdditionalParameter <Object>]


  • -ComputerName: Specifies the name of the computer to be restarted. If omitted, the local computer will be restarted.
  • -Credential: Specifies a PSCredential object containing the credentials for a user account that has permissions to restart the computer remotely.
  • -Force: Forces the restart without prompting the user for confirmation.
  • -WhatIf: Performs a simulation of the command without actually restarting the computer. It shows what would happen if the command were executed.
  • -Confirm: Prompts the user for confirmation before restarting the computer.


Example 1: Restarting Local Computer


Example 2: Restarting Remote Computer with Credentials

$credential = Get-Credential
Restart-Computer -ComputerName server1 -Credential $credential

Example 3: Forcefully Restarting Remote Computer

Restart-Computer -ComputerName server2 -Force

Common Issues

  • Access Denied Error: Ensure that the user account used to execute the command has administrative privileges on the target computer.
  • Computer Not Found: Verify that the computer name or IP address specified in the -ComputerName parameter is correct.
  • Pending Updates: If there are pending software updates on the target computer, the restart may be delayed until those updates are applied.


The Restart-Computer command can be combined with other PowerShell commands or tools for advanced tasks:

  • Scheduled Restarts: Use ScheduledTask module to create a scheduled task that regularly restarts the computer.
  • Remote Shutdown Scripts: Write a script that uses Restart-Computer to restart multiple remote computers simultaneously.
  • Troubleshooting Connectivity Issues: Use Invoke-Command to remotely execute the Restart-Computer command on a computer that is experiencing connectivity issues.
  • Shutdown-Computer: Shuts down a local or remote computer.
  • New-ScheduledTask: Creates a scheduled task to automate repetitive tasks, including computer restarts.
  • Invoke-Command: Executes commands on remote computers.