Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Suspend-Service

Updated: October 17, 2013

Applies To: Windows PowerShell 4.0

Suspend-Service

Suspends (pauses) one or more running services.

Syntax

Parameter Set: InputObject
Suspend-Service [-InputObject] <ServiceController[]> [-Exclude <String[]> ] [-Include <String[]> ] [-PassThru] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: Default
Suspend-Service [-Name] <String[]> [-Exclude <String[]> ] [-Include <String[]> ] [-PassThru] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: DisplayName
Suspend-Service -DisplayName <String[]> [-Exclude <String[]> ] [-Include <String[]> ] [-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

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

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: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see  about_CommonParameters (http://go.microsoft.com/fwlink/p/?LinkID=113216).

Inputs

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

  • System.ServiceProcess.ServiceController or System.String

    You can pipe a service object or a string that contains a service name to Suspend-Service.


Outputs

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

  • None or System.ServiceProcess.ServiceController

    When you use the PassThru parameter, Suspend-Service generates a System.ServiceProcess.ServiceController object representing the service. Otherwise, this cmdlet does not generate any output.


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

Related topics



Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.