Stop-Computer
SYNOPSIS
Stops (shuts down) local and remote computers.
SYNTAX
Stop-Computer [-WsmanAuthentication <String>] [[-ComputerName] <String[]>] [[-Credential] <PSCredential>]
[-Force] [-WhatIf] [-Confirm] [<CommonParameters>]
DESCRIPTION
The `Stop-Computer` cmdlet shuts down the local computer and remote computers.
You can use the parameters of `Stop-Computer` to specify the authentication levels and alternate credentials, and to force an immediate shut down.
In PowerShell 7.1, `Stop-Computer` was added for Linux and macOS. The parameters have no effect on these platforms. The cmdlet is just calling the native command `/sbin/shutdown`.
EXAMPLES
Example 1: Shut down the local computer
Stop-Computer -ComputerName localhost
Example 2: Shut down two remote computers and the local computer
Stop-Computer -ComputerName "Server01", "Server02", "localhost"
`Stop-Computer` uses the ComputerName parameter to specify two remote computers and the local computer. Each computer is shut down.
Example 3: Shut down remote computers as a background job
$j = Stop-Computer -ComputerName "Server01", "Server02" &
$results = $j | Receive-Job
$results
`Stop-Computer` uses the ComputerName parameter to specify two remote computers. The `&` background operator runs the command as a background job. The job objects are stored in the `$j` variable.
The job objects in the `$j` variable are sent down the pipeline to `Receive-Job`, which gets the job results. The objects are stored in the `$results` variable. The `$results` variable displays the job information in the PowerShell console.
Example 4: Shut down a remote computer
Stop-Computer -ComputerName "Server01" -WsmanAuthentication Kerberos
`Stop-Computer` uses the ComputerName parameter to specify the remote computer. The WsmanAuthentication parameter specifies to use Kerberos to establish a remote connection.
Example 5: Shut down computers in a domain
$s = Get-Content -Path ./Domain01.txt
$c = Get-Credential -Credential Domain01\Admin01
Stop-Computer -ComputerName $s -Force -Credential $c
`Get-Content` uses the Path parameter to get a file in the current directory with the list of domain computers. The objects are stored in the `$s` variable.
`Get-Credential` uses the Credential parameter to specify the credentials of a domain administrator. The credentials are stored in the `$c` variable.
`Stop-Computer` shuts down the computers specified with the ComputerName parameter's list of computers in the `$s` variable. The Force parameter forces an immediate shutdown. The Credential parameter submits the credentials saved in the `$c` variable.
PARAMETERS
-ComputerName
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 doesn't rely on PowerShell remoting. You can use the ComputerName parameter even if your computer isn't configured to run remote commands.
Type: System.String[]
Parameter Sets: (All)
Aliases: CN, __SERVER, Server, IPAddress
Required: False
Position: 0
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
-Credential
Specifies a user account that has permission to do this action. The default is the current user.
Type a user name, such as User01 or Domain01\User01 , or enter a PSCredential object generated by the `Get-Credential` cmdlet. If you type a user name, you're prompted to enter the password.
Credentials are stored in a PSCredential (/dotnet/api/system.management.automation.pscredential)object and the password is stored as a SecureString (/dotnet/api/system.security.securestring).
> [!NOTE] > For more information about SecureString data protection, see > How secure is SecureString? (/dotnet/api/system.security.securestring#how-secure-is-securestring).
Type: System.Management.Automation.PSCredential
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: Current user
Accept pipeline input: False
Accept wildcard characters: False
-Force
Forces an immediate shut down of the computer.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
-WsmanAuthentication
Specifies the mechanism that is used to authenticate the user credentials when this cmdlet uses the WSMan protocol. The default value is Default .
The acceptable values for this parameter are:
- Basic
- CredSSP
- Default
- Digest
- Kerberos
- Negotiate.
For more information about the values of this parameter, see AuthenticationMechanism (/dotnet/api/system.management.automation.runspaces.authenticationmechanism).
> [!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 PowerShell 3.0.
Type: System.String
Parameter Sets: (All)
Aliases:
Accepted values: Default, Basic, Negotiate, CredSSP, Digest, Kerberos
Required: False
Position: Named
Default value: Default
Accept pipeline input: False
Accept wildcard characters: False
-Confirm
Prompts you for confirmation before running the cmdlet.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: cf
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 isn't run.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: wi
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
None
You can't pipe input to this cmdlet.
OUTPUTS
None
NOTES
This cmdlet uses the Win32Shutdown method of the Win32_OperatingSystem WMI class. This method requires the SeShutdownPrivilege privilege be enabled for the user account used to restart the machine.
In PowerShell 7.1, `Stop-Computer` was added for Linux and macOS. For these platorms, the cmdlet calls the native command `/sbin/shutdown`.