CmdID / PowerShell / Cmdlets / Restart
Restart-Computer
Restarts the operating system on local and remote computers. PowerShell reference
From the PowerShell reference 15 parameters
What it does
Restarts the operating system on local and remote computers. The Restart-Computer cmdlet restarts the operating system on the local and remote computers. You can use the parameters of Restart-Computer to run the restart operations as a background job, to specify the authentication levels and alternate credentials, to limit the operations that run at the same time, and to force an immediate restart. Starting in Windows PowerShell 3.0, you can wait for the restart to complete before you run the next command. Specify a waiting time-out and query interval, and wait for particular services to be available on the restarted computer. This feature makes it practical to use Restart-Computer in scripts and functions. You can use the WS-Management (WSMan) protocol to restart the computer, in case Distributed Component Object Model (DCOM) calls are blocked, such as by an enterprise firewall. For more information, see WS-Management Protocol. This cmdlet requires Windows PowerShell remoting only when you use the AsJob parameter in a command.
Restart-Computer [-DcomAuthentication <AuthenticationLevel>] [-Impersonation <ImpersonationLevel>] [-WsmanAuthentication <String>] [-Protocol <String>] [[-ComputerName] <String[]>] [[-Credential] <PSCredential>] [-Force] [-Wait] [-Timeout <Int32>] [-For <WaitForServiceTypes>] [-Delay <Int16>] [-WhatIf] [-Confirm] [<CommonParameters>]Restart-Computer [-AsJob] [-DcomAuthentication <AuthenticationLevel>] [-Impersonation <ImpersonationLevel>] [[-ComputerName] <String[]>] [[-Credential] <PSCredential>] [-Force] [-ThrottleLimit <Int32>] [-WhatIf] [-Confirm] [<CommonParameters>]
Restart the local computer
Restart-ComputerIdentifyRestart multiple computers
Restart-Computer -ComputerName Server01, Server02, localhostIdentifyRestart computers as a background job
$Job = Restart-Computer -ComputerName "Server01", "Server02" -AsJob
$Job | Receive-JobIdentifyRestart a remote computer
Restart-Computer -ComputerName Server01 -Impersonation Anonymous -DcomAuthentication PacketIntegrityIdentifyForce restart of computers listed in a text file
$Names = Get-Content -Path C:\Domain01.txt
$Creds = Get-Credential
Restart-Computer -ComputerName $Names -Credential $Creds -Force -ThrottleLimit 10IdentifyRestart a remote computer and wait for PowerShell
Restart-Computer -ComputerName Server01 -Wait -For PowerShell -Timeout 300 -Delay 2IdentifyRestart a computer by using the WSMan Protocol
Restart-Computer -ComputerName Server01 -Protocol WSMan -WsmanAuthentication KerberosIdentifyIts page in the reference: Restart-Computer.
Parameters
-AsJobIndicates that Restart-Computer runs as a background job.
To use this parameter, the local and remote computers must be configured for remoting. On Windows Vista and later versions of the Windows operating system, you must open PowerShell by using the Run as Administrator option. For more information, see about_Remote_Requirements.
When you specify the AsJob parameter, the command immediately returns an object that represents
the background job. You can continue to work in the session while the job finishes. The job is
created on the local computer and the 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 the
Receive-Job cmdlet.
For more information about Windows PowerShell background jobs, see about_Jobs and about_Remote_Jobs.-ComputerNameSpecifies one computer name or a comma-separated array of computer names. Restart-Computer accepts ComputerName objects from the pipeline or variables.
This parameter doesn't rely on PowerShell remoting. You can use the ComputerName parameter even if your computer isn't configured to run remote commands.
If the ComputerName parameter isn't specified, Restart-Computer restarts the local computer.-CredentialSpecifies a user account that has permission to do this action. The default is the current user.
Credentials are stored in a PSCredential object and the password is stored as a SecureString.
NOTE: For more information about SecureString data protection, see How secure is SecureString?.-DcomAuthenticationSpecifies the authentication level that is used for the WMI connection. Restart-Computer uses WMI.
Valid values are:
- Call: Call-level COM authentication
- Connect: Connect-level COM authentication
- Default: Windows Authentication
- None: No COM authentication
- Packet: Packet-level COM authentication.
- PacketIntegrity: Packet Integrity-level COM authentication
- PacketPrivacy: Packet Privacy-level COM authentication.
- Unchanged: The authentication level is the same as the previous command.
For more information, see AuthenticationLevel Enumeration.
This parameter is introduced in Windows PowerShell 3.0.-DelaySpecifies 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.-ForSpecifies the behavior of PowerShell as it waits for the specified service or feature to become available after the computer restarts. This parameter is only valid with the Wait parameter.
The acceptable values for this parameter are:
- Default: Waits for PowerShell to restart.
- PowerShell: Can run commands in a PowerShell remote session on the computer.
- WMI: Receives a reply to a Win32_ComputerSystem query for the computer.
- WinRM: Can establish a remote session to the computer by using WS-Management.
This parameter was introduced in Windows PowerShell 3.0.-ForceForces an immediate restart of the computer.-ImpersonationSpecifies the impersonation level that this cmdlet uses to call WMI. Restart-Computer uses WMI. The acceptable values for this parameter are:
- Default: Default impersonation. Despite the name, this isn't the default value.
- Anonymous: Hides the identity of the caller.
- Identify: Allows objects to query the credentials of the caller.
- Impersonate: Allows objects to use the credentials of the caller.-ProtocolSpecifies which protocol to use to restart the computers. The valid values are WSMan and DCOM.
This parameter is introduced in Windows PowerShell 3.0.-ThrottleLimitSpecifies the maximum number of concurrent connections that can be established to run this command. The throttle limit applies only to the current command, not to the session or to the computer.
If the ThrottleLimit parameter isn't specified or a value of 0 is used, Restart-Computer uses a maximum of 32 concurrent connections.-TimeoutSpecifies the duration of the wait, in seconds. When the timeout elapses, Restart-Computer returns to the command prompt, even if the computers aren't restarted.
The Timeout parameter is only valid with the Wait parameter. Timeout overrides the Wait parameter's indefinite waiting period.
This parameter was introduced in Windows PowerShell 3.0.-WaitRestart-Computer suppresses the PowerShell prompt and blocks the pipeline until the computers have restarted. You can use this parameter in a script to restart computers and then continue to process when the restart is finished.
The Wait parameter waits indefinitely for the computers to restart. You can use Timeout to adjust the timing and the For and Delay parameters to wait for particular services to become available on the restarted computers.
The Wait parameter isn't valid when you're restarting the local computer. If the value of the
ComputerName parameter contains the names of remote computers and the local computer,
Restart-Computer generates a non-terminating error for Wait on the local computer, but waits
for the remote computers to restart.
This parameter was introduced in Windows PowerShell 3.0.-WsmanAuthenticationSpecifies the mechanism that is used to authenticate the user credentials. This parameter was introduced in Windows PowerShell 3.0.
The acceptable values for this parameter are: Basic, CredSSP, Default, Digest, Kerberos, and Negotiate.
For more information, see AuthenticationMechanism.
WARNING: Credential Security Service Provider (CredSSP) authentication, in which the user credentials are passed to a remote computer to be authenticated, is designed for commands that require authentication on more than one resource, such as accessing a remote network share. This mechanism increases the security risk of the remote operation. If the remote computer is compromised, the credentials that are passed to it can be used to control the network session.-ConfirmPrompts you for confirmation before running Restart-Computer.-WhatIfShows what would happen if the Restart-Computer runs. The Restart-Computer cmdlet isn't run.