Stop-Computer

Updated: August 9, 2015

Stop-Computer

Stops (shuts down) local and remote computers.

Syntax

Parameter Set: Default
Stop-Computer [[-ComputerName] <String[]> ] [[-Credential] <PSCredential> ] [-AsJob] [-DcomAuthentication <System.Management.AuthenticationLevel> {Default | None | Connect | Call | Packet | PacketIntegrity | PacketPrivacy | Unchanged} ] [-Force] [-Impersonation <ImpersonationLevel> {Default | Anonymous | Identify | Impersonate | Delegate} ] [-Protocol <String> {DCOM | WSMan} ] [-ThrottleLimit <Int32> ] [-WsmanAuthentication <String> {Default | Basic | Negotiate | CredSSP | Digest | Kerberos} ] [-Confirm] [-WhatIf] [ <CommonParameters>]




Detailed Description

The Stop-Computer cmdlet shuts down computers remotely. It can also shut down the local computer.

You can use the parameters of Stop-Computer to run the shutdown operations as a background job, to specify the authentication levels and alternate credentials, to limit the concurrent connections that are created to run the command, and to force an immediate shut down.

This cmdlet does not require Windows PowerShell remoting unless you use the AsJob parameter.

Parameters

-AsJob

Indicates that this cmdlet runs as a background job.

To use this parameter, the local and remote computers must be configured for remoting and, on Windows Vista and later versions of the Windows operating system, you must open Windows 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 get the job results, use the Receive-Job cmdlet.

For more information about Windows PowerShell background jobs, see about_Jobs and about_Remote_Jobs.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ComputerName<String[]>

Specifies the computers to stop. The default is the local computer.

Type the NETBIOS name, IP address, or fully qualified domain name of one or more computers in a comma-separated list. To specify the local computer, type the computer name or localhost.

This parameter does not rely on Windows PowerShell remoting. You can use the ComputerName parameter even if your computer is not configured to run remote commands.


Aliases

CN, __SERVER, Server, IPAddress

Required?

false

Position?

1

Default Value

none

Accept Pipeline Input?

true (ByPropertyName)

Accept Wildcard Characters?

false

-Credential<PSCredential>

Specifies a user account that has permission to perform this action. The default is the current user.

Type a user name, such as User01 or Domain01\User01, or enter a PSCredential object, such as one from the Get-Credential cmdlet.


Aliases

none

Required?

false

Position?

2

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-DcomAuthentication<System.Management.AuthenticationLevel>

Specifies the authentication level that this cmdlet uses with WMI. Stop-Computer uses WMI. The acceptable values for this parameter are:

-- 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
-- Unchanged. Same as the previous command

The default value is Packet.

For more information about the values of this parameter, see AuthenticationLevel Enumeration (http://go.microsoft.com/fwlink/?LinkID=235229) in the Microsoft Developer Library (MSDN).


Aliases

Authentication

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Force

Forces an immediate shut down of the computers.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Impersonation<ImpersonationLevel>

Specifies the impersonation level to use when this cmdlet calls WMI. Stop-Computer uses WMI. The acceptable values for this parameter are:

-- Default. Default impersonation.
-- 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.

The default value is Impersonate.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Protocol<String>

Specifies which protocol to use to restart the computers. The acceptable values for this parameter are: WSMan and DCOM. The default value is DCOM.

This parameter was introduced in Windows PowerShell 3.0.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ThrottleLimit<Int32>

Specifies the maximum number of concurrent connections that can be established to run this command. If you omit this parameter or enter a value of 0, the default value, 32, is used.

The throttle limit applies only to the current command, not to the session or to the computer.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-WsmanAuthentication<String>

Specifies the mechanism that is used to authenticate the user credentials when this cmdlet uses the WSMan protocol. The acceptable values for this parameter are:

-- Basic
-- CredSSP
-- Default
-- Digest
-- Kerberos
-- Negotiate.

The default value is Default.

For more information about the values of this parameter, see AuthenticationMechanism Enumeration (http://go.microsoft.com/fwlink/?LinkID=235230) in the MSDN library.

Caution: 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.

This parameter was introduced in Windows PowerShell 3.0.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Confirm

Prompts you for confirmation before running the cmdlet.


Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.


Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see    about_CommonParameters.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • None

    You cannot pipe input to this cmdlet.


Outputs

The output type is the type of the objects that the cmdlet emits.

  • None or System.Management.Automation.RemotingJob

    The cmdlet returns a System.Management.Automation.RemotingJob object, if you specify the AsJob parameter. Otherwise, it does not generate any output.


Notes

  • This cmdlet uses the Win32Shutdown method of the Win32_OperatingSystem WMI class.

  • In Windows PowerShell 2.0, the AsJob parameter does not work reliably when you are restarting/stopping remote computers. In Windows PowerShell 3.0, the implementation is changed to resolve this problem.

Examples

Example 1: Shut down the local computer

This command shuts down the local computer.


PS C:\> Stop-Computer

Example 2: Shut down two remote computers and the local computer

This command stops two remote computers, Server01 and Server02, and the local computer, identified as localhost.


PS C:\> Stop-Computer -ComputerName "Server01", "Server02", "localhost"

Example 3: Shut down remote computers as a background job

These commands run Stop-Computer as a background job on two remote computers, and then get the results.

The first command specifies the AsJob parameter to run the command as a background job. The command saves the resulting job object in the $j variable.

The second command uses a pipeline operator to send the job object in $j to Receive-Job, which gets the job results. The command saves the results in the $results variable.

The third command displays the result saved in the $results variable.

Because AsJob creates the job on the local computer and automatically returns the results to the local computer, you can run Receive-Job as a local command.


PS C:\> $j = Stop-Computer -ComputerName "Server01", "Server02" -AsJob
PS C:\> $results = $j | Receive-Job
PS C:\> $results

Example 4: Shut down a remote computer

This command stops the Server01 remote computer. The command uses customized impersonation and authentication settings.


PS C:\> Stop-Computer -CompupterName "Server01" -Impersonation anonymous -Authentication PacketIntegrity

Example 5:

These commands force an immediate shut down of all of the computers in Domain01.

The first command gets a list of computers in the domain, and then stores them in the $s variable.

The second command gets the credentials of a domain administrator, and then stores them in the $c variable.

The third command shuts down the computers. It uses ComputerName parameter to submit the list of computers in the $s variable, the Force parameter to force an immediate shutdown, and the Credential parameter to submit the credentials saved in the $c variable. It also uses the ThrottleLimit parameter to limit the command to 10 concurrent connections.


PS C:\> $s = Get-Content Domain01.txt
PS C:\> $c = Get-Credential domain01\admin01
PS C:\> Stop-Computer -ComputerName $s -Force -ThrottleLimit 10 -Credential $c

Related topics

Community Additions

ADD
Show: