Before you start
1. Administrator rights
Open PowerShell as Administrator (right-click it and choose Run as administrator).
2. Execution policy
Check the policy that controls scripts:
Get-ExecutionPolicy

If it is Restricted, you cannot run scripts. Restart-Computer is a cmdlet and works anyway, but scripts need a looser policy:
Set-ExecutionPolicy RemoteSigned

3. PowerShell remoting (for remote servers)
To restart a remote server, enable remoting on it:
Enable-PSRemoting -Force

Restart the local server
Restart-Computer

Useful options
Force the restart even if users are logged on or programs are open:
Restart-Computer -Force

Ask for a confirmation:
Restart-Computer -Confirm

Show what would happen without doing it:
Restart-Computer -WhatIf
Restart a remote server
Restart-Computer -ComputerName "Server01"
With other credentials:
Restart-Computer -ComputerName "Server01" -Credential (Get-Credential)
Several servers at once:
Restart-Computer -ComputerName "Server01","Server02" -Force
Wait until a remote server is back before the script goes on:
Restart-Computer -ComputerName "Server01" -Wait -For PowerShell -Timeout 300
Other ways
The classic command also works in PowerShell or Command Prompt:
shutdown /r /t 0
/r restarts and /t 0 sets zero seconds of delay.
Warning: A forced restart can lose unsaved data. Use it when you must, and warn the users first.
Quick recap
- Run
Restart-Computeras administrator. - Add
-ComputerNamefor a remote server and-Forceto close programs.