Suspend-Service

 

Additional Resources for Suspend-Service

 

Pausing a Running Service

http://www.microsoft.com/technet/scriptcenter/topics/msh/cmdlets/suspend-service.mspx

 

 

SYNOPSIS

Suspends (pauses) one or more running services.

 

SYNTAX

Suspend-Service [-name] <string[]> [-passthru] [-include <string[]>] [-exclude <string[]>] [-whatIf] [-confirm] [<CommonParameters>]

 

Suspend-Service -displayName <string[]> [-passthru] [-include <string[]>] [-exclude <string[]>] [-whatIf] [-confirm] [<CommonParameters>]

 

Suspend-Service [-passthru] [-inputObject <ServiceController[]>] [-include <string[]>] [-exclude <string[]>] [-whatIf] [-confirm] [<CommonParameters>]

 

DETAILED DESCRIPTION

The Suspend-Service cmdlet sends a suspend message to the  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

 

-name <string[]>

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

 

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

 

Required?

true

Position?

1

Default value

 

Accept pipeline input?  

true (ByValue, ByPropertyName)

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.

 

Required?

false

Position?

named

Default value

 

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.

 

Required?

false

Position?

named

Default value

 

Accept pipeline input?  

false

Accept wildcard characters? 

true

 

-displayName <string[]>

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

 

Required?

true

Position?

named

Default value

 

Accept pipeline input?  

false

Accept wildcard characters? 

true

 

-passthru <SwitchParameter>

Passes the object created by this cmdlet through the pipeline. By default, this cmdlet does not pass any objects through the pipeline.

 

Required?

false

Position?

named

Default value

False

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-inputObject <ServiceController[]>

Suspends the services represented by the specified ServiceController objects. Enter a variable that contains the objects or type a command or expression that gets the objects.

 

Required?

false

Position?

named

Default value

 

Accept pipeline input?  

true (ByValue)

Accept wildcard characters? 

false

 

-whatIf

Describes what would happen if you executed the command without actually executing the command.

 

Required?                                         

false

Position?

named

Default value

 

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-confirm

Prompts you for confirmation before executing the command.

 

Required?

false

Position?

named

Default value

 

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

<CommonParameters>

trace-command parameterbinding {get-alias $input} -pshost -inputobject $a 

INPUT TYPE

Object

 

NOTES

 

For more information, type "Get-Help Suspend-Service -detailed". For technical information, type "Get-Help Suspend-Service -full".

 

When specifying multiple values for a parameter, use commas to separate the values. For example, "<parameter-name> <value1>, <value2>".

 

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 only suspend services that support being suspended and resumed. To determine whether a particular service can be suspended, use the Get-Servicecmdlet 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 {$_.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.

 

EXAMPLE 1

 

suspend-service -displayname "Telnet"

 

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

 

EXAMPLE 2

 

suspend-service -name lanman* -whatif

 

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.

 

EXAMPLE 3

 

get-service schedule | suspend-service

 

This command uses the Get-Servicecmdlet 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.

 

EXAMPLE 4

 

get-service | where-object {$_.canpauseandcontinue -eq "True"} | suspend-service -confirm

 

This command suspends all of the services on the computer that can be suspended. It uses the Get-Servicecmdlet to get objects representing the services on the computer. The pipeline operator (|) passes the results to the Where-Objectcmdlet 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.

 

RELATED LINKS

Get-Service

Start-Service

Stop-Service

Restart-Service

Resume-Service

Set-Service

New-Service