< Back

Stop-Computer

Tue Jan 29, 2019 10:20 pm

NAME Stop-Computer



SYNOPSIS

Stops (shuts down) local and remote computers.





SYNTAX

Stop-Computer [[-ComputerName] <String[]>] [[-Credential] <PSCredential>] [-AsJob] [-Confirm] [-DcomAuthentication {Default | None | Connect |

Call | Packet | PacketIntegrity | PacketPrivacy | Unchanged}] [-Force] [-Impersonation {Default | Anonymous | Identify | Impersonate | Delegate}]

[-Protocol {DCOM | WSMan}] [-ThrottleLimit <Int32>] [-WhatIf] [-WsmanAuthentication {Default | Basic | Negotiate | CredSSP | Digest | Kerberos}]

[<CommonParameters>]





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 [<SwitchParameter>]

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.



Required? false

Position? named

Default value False

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.



Required? false

Position? 0

Default value None

Accept pipeline input? True (ByPropertyName)

Accept wildcard characters? false



-Confirm [<SwitchParameter>]

Prompts you for confirmation before running the cmdlet.



Required? false

Position? named

Default value False

Accept pipeline input? False

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.



Required? false

Position? 1

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-DcomAuthentication <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 Enumerationhttp://go.microsoft.com/fwlink/?LinkID=235229

(http://go.microsoft.com/fwlink/?LinkID=235229) in the Microsoft Developer Library (MSDN).



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-Force [<SwitchParameter>]

Forces an immediate shut down of the computers.



Required? false

Position? named

Default value False

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.



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.



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.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



-WhatIf [<SwitchParameter>]

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



-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 Enumerationhttp://go.microsoft.com/fwlink/?LinkID=235230

(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.





Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).



INPUTS

None

You cannot pipe input to this cmdlet.





OUTPUTS

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.



Example 1: Shut down the local computer



PS C:\\>Stop-Computer



This command shuts down the local computer.

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



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



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

Example 3: Shut down remote computers as a background job



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

PS C:\\> $results = $j | Receive-Job

PS C:\\> $results



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.

Example 4: Shut down a remote computer



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



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

Example 5:



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



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.



RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/?LinkId=821641

Add-Computer

Checkpoint-Computer

Remove-Computer

Rename-Computer

Restart-Computer

Restore-Computer

Test-Connection