Cmdlets

Choose a cmdlet from the list on the left or search for a specific cmdlet. Choose a cmdlet from the list or search for a specific cmdlet.
About Help  Providers
 

Suspend-Service

Suspend-Service

microsoft.powershell.commands.management.dll

Synopsis

Suspends (pauses) one or more running services.

Syntax

Suspend-Service [-InputObject] [-Exclude] [-Include] [-PassThru] [-Confirm] [-WhatIf] [<CommonParameters>]

Suspend-Service [-Exclude] [-Include] [-PassThru] [-DisplayName] [-Confirm] [-WhatIf] [<CommonParameters>]

Suspend-Service [-Name] [-Exclude] [-Include] [-PassThru] [-Confirm] [-WhatIf] [<CommonParameters>]

Detailed Description

The Suspend-Service cmdlet sends a suspend message to the Windows Service Controller for each of the specified services. While suspended, the service is still running, but its action is halted until resumed, such as by using Resume-Service. You can specify the services by their service names or display names, or you can use the InputObject parameter to pass a service object representing the services that you want to suspend.

Parameters

-DisplayName <String[]>

Specifies the display names of the services to be suspended. Wildcards are permitted.

Aliases

None

Required?

true

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

true

-Exclude <String[]>

Omits the specified services. The value of this parameter qualifies the Name parameter. Enter a name element or pattern, such as "s*". Wildcards are permitted.

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

true

-Include <String[]>

Suspends only the specified services. The value of this parameter qualifies the Name parameter. Enter a name element or pattern, such as "s*". Wildcards are permitted.

Aliases

None

Required?

false

Position

named

Default value

None

Accept pipeline input?

false

Accept wildcard characters?

true

-InputObject <ServiceController[]>

Specifies ServiceController objects representing the services to be suspended. Enter a variable that contains the objects, or type a command or expression that gets the objects.

Aliases

None

Required?

true

Position

1

Default value

None

Accept pipeline input?

true (ByValue)

Accept wildcard characters?

false

-Name <String[]>

Specifies the service names of the services to be suspended. Wildcards are permitted.

The parameter name is optional. You can use "Name" or its alias, "ServiceName", or you can omit the parameter name.

Aliases

None

Required?

true

Position

1

Default value

None

Accept pipeline input?

true (ByPropertyName, ByValue)

Accept wildcard characters?

true

-PassThru <SwitchParameter>

Returns an object representing the service. By default, this cmdlet does not generate any output.

Aliases

None

Required?

false

Position

named

Default value

False

Accept pipeline input?

false

Accept wildcard characters?

false

-Confirm <SwitchParameter>

Prompts you for confirmation before running the cmdlet.

Aliases

None

Required?

false

Position

named

Default value

false

Accept pipeline input?

false

Accept wildcard characters?

false

-WhatIf <SwitchParameter>

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

Aliases

None

Required?

false

Position

named

Default value

false

Accept pipeline input?

false

Accept wildcard characters?

false

Input Type

System.ServiceProcess.ServiceController or System.String

Return Type

None or System.ServiceProcess.ServiceController

Notes

Suspend-Service can control services only when the current user has permission to do so. If a command does not work correctly, you might not have the required permissions.

Also, Suspend-Service can suspend only services that support being suspended and resumed. To determine whether a particular service can be suspended, use the Get-Service cmdlet with the CanPauseAndContinue property. For example, "get-service wmi | format-list name, canpauseandcontinue". To find all services on the computer that can be suspended, type "get-service | where-object {$_.canpauseandcontinue -eq "True"}".

To find the service names and display names of the services on your system, type "get-service". The service names appear in the Name column, and the display names appear in the DisplayName column.

Examples

-------------------------- EXAMPLE 1 --------------------------

This command suspends the Telnet service (Tlntsvr) service on the local computer.

PS C:\>suspend-service -displayname "Telnet"

-------------------------- EXAMPLE 2 --------------------------

This command tells what would happen if you suspended the services that have a service name that begins with "lanman". To suspend the services, rerun the command without the WhatIf parameter.

PS C:\>suspend-service -name lanman* -whatif

-------------------------- EXAMPLE 3 --------------------------

This command uses the Get-Service cmdlet to get an object that represents the Task Scheduler (Schedule) service on the computer. The pipeline operator (|) passes the result to the Suspend-Service cmdlet, which suspends the service.

PS C:\>get-service schedule | suspend-service

-------------------------- EXAMPLE 4 --------------------------

This command suspends all of the services on the computer that can be suspended. It uses the Get-Service cmdlet to get objects representing the services on the computer. The pipeline operator (|) passes the results to the Where-Object cmdlet, which selects only the services that have a value of "True" for the CanPauseAndContinue property. Another pipeline operator passes the results to the Suspend-Service cmdlet. The Confirm parameter prompts you for confirmation before suspending each of the services.

PS C:\>get-service | where-object {$_.canpauseandcontinue -eq "True"} | suspend-service -confirm

Online Version
Get-Service
New-Service
Restart-Service
Resume-Service
Set-Service
Start-Service
Stop-Service