Restart ("reboot") the operating system on local and remote computers.
Syntax (PowerShell 5.1 ) Restart-Computer [[-ComputerName] string] [[-Credential] PSCredential] [-AsJob] [-Authentication AuthenticationLevel] [-Delay Int16] [-For WaitForServiceTypes] [-Force] [-WsmanAuthentication String] [-Impersonation ImpersonationLevel] [-DcomAuthentication AuthenticationLevel] [-ThrottleLimit int] [-Confirm] [-WhatIf] [CommonParameters] Syntax (PowerShell 7.1 ) Restart-Computer [[-ComputerName] String] [[-Credential]PSCredential] [-WsmanAuthentication String] [-Delay Int16] [-For WaitForServiceTypes] [-Force] [-Wait] [-Timeout Int32] [-Confirm] [-WhatIf] [CommonParameters] Key -AsJob Run the command as a background job. When this parameter is used, Restart-Computer will immediately return an object that represents the background job. You can continue to work in the session while the job completes. The job is created on the local computer and results from remote computers are automatically returned to the local computer. To manage the job, use the Job cmdlets. To get the job results, use Receive-Job. To use this parameter, the local and remote computers must be configured for remoting. On Windows Vista and later, you must open PowerShell with the "Run as administrator" option. -Authentication AuthenticationLevel The authentication level that is used for the WMI connection. (Restart-Computer uses WMI.) The default value is Packet. Valid values are: Unchanged The authentication level is the same as the previous command. Default Windows Authentication None No COM authentication Connect Connect-level COM authentication Call Call-level COM authentication Packet Packet-level COM authentication. PacketIntegrity Packet Integrity-level COM authentication PacketPrivacy Packet Privacy-level COM authentication. -ComputerName string One or more remote computers. The default is the local computer. Type the NETBIOS name, an IP address, or a fully qualified domain name of a remote computer. To specify the local computer, type the computer name, a dot (.), or "localhost". This parameter does not rely on PowerShell remoting. -Credential PSCredential A user account that has permission to perform this action. The default is the current user. Type a user name, such as "User64" or "Domain64\User64", or enter a PSCredential object, such as one generated by Get-Credential. If you type a user name, you will be prompted for a password. -Delay The frequency of queries, in seconds. PowerShell queries the service specified by the For parameter to determine whether the service is available after the computer is restarted. This parameter is valid only together with the -Wait and -For parameters. This parameter was introduced in Windows PowerShell 3.0. If the Delay parameter isn’t specified, Restart-Computer uses a five second delay. -Force Force an immediate restart of the computer(s). -Impersonation ImpersonationLevel The impersonation level to use when calling WMI. (Restart-Computer uses WMI.) The default value is "Impersonate". Valid values are: Default Default impersonation. Delegate Delegate impersonation. Anonymous Hide the identity of the caller. Identify Allow objects to query the credentials of the caller. Impersonate Allow objects to use the credentials of the caller. -ThrottleLimit int The maximum number of concurrent connections that can be established to run this command. If this parameter is set to 0, or omitted, the default value of 32, is used. The throttle limit applies only to the current command, not to the session. -confirm Prompt for confirmation before executing the command. -whatIf Describe what would happen if you executed the command without actually executing the command.
Restart-Computer restarts the operating system on the local and remote computers.
Use the parameters of Restart-Computer to run the restart operation as a background job, to specify the authentication levels and alternate credentials, to limit the operations that run concurrently, and to force an immediate restart.
The -AsJob parameter will require Windows PowerShell remoting.
Restart the local computer:
PS C:> restart-computer
Restart two remote computers, and the local computer:
PS C:> restart-computer -computername Server64, Server65, localhost
Run a Restart-Computer command as a background job on two remote computers, and then get the results:
PS C:> $job = restart-computer -computername Server64, Server65 -asjob
PS C:> $results = $job | receive-job
PS C:> $results
Restart a list of computers:
PS C:> $machines = get-content E:\servers.txt
PS C:> $creds = get-credential domain64\admin64
PS C:> restart-computer -computername $machines -force -throttlelimit 10 -credential $creds
Open the Windows Shutdown/Restart dialogue box:
PS C:> (New-Object -ComObject Shell.Application).ShutdownWindows()
“Life is not about how fast you run, or how high you climb, but how well you bounce” ~ Unknown
Add-Computer - Add a computer to the domain.
Stop-Computer - Stop/Shutdown computer.
Remove-Computer - Remove the local computer from a workgroup or domain.
CMD command: shutdown