다음을 통해 공유


Suspend-Service

Suspends (pauses) one or more running services.

구문

InputObject (기본값)

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

Default

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

DisplayName

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

Description

This cmdlet is only available on the Windows platform.

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 stopped until resumed, such as by using the Resume-Service cmdlet. You can specify the services by their service names or display names, or you can use the InputObject parameter to pass a service object that represents the services that you want to suspend.

예제

Example 1: Suspend a service

Suspend-Service -DisplayName "Telnet"

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

Example 2: Display what would happen if you suspend services

Suspend-Service -Name lanman* -WhatIf

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

Example 3: Get and suspend a service

Get-Service schedule | Suspend-Service

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 Suspend-Service, which suspends the service.

Example 4: Suspend all services that can be suspended

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 Get-Service to get objects that represent 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 Suspend-Service. The Confirm parameter prompts you for confirmation before suspending each of the services.

매개 변수

-Confirm

Prompts you for confirmation before running the cmdlet.

매개 변수 속성

형식:SwitchParameter
Default value:False
와일드카드 지원:False
DontShow:False
별칭:cf

매개 변수 집합

(All)
Position:Named
필수:False
파이프라인의 값:False
속성 이름별 파이프라인의 값:False
나머지 인수의 값:False

-DisplayName

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

매개 변수 속성

형식:

String[]

Default value:None
와일드카드 지원:True
DontShow:False

매개 변수 집합

DisplayName
Position:Named
필수:True
파이프라인의 값:False
속성 이름별 파이프라인의 값:False
나머지 인수의 값:False

-Exclude

Specifies services to omit from the specified services. The value of this parameter qualifies the Name parameter. Enter a name element or pattern, such as "s*". Wildcard characters are permitted.

매개 변수 속성

형식:

String[]

Default value:None
와일드카드 지원:True
DontShow:False

매개 변수 집합

(All)
Position:Named
필수:False
파이프라인의 값:False
속성 이름별 파이프라인의 값:False
나머지 인수의 값:False

-Include

Specifies services to suspend. The value of this parameter qualifies the Name parameter. Enter a name element or pattern, such as "s*". Wildcard characters are permitted.

매개 변수 속성

형식:

String[]

Default value:None
와일드카드 지원:True
DontShow:False

매개 변수 집합

(All)
Position:Named
필수:False
파이프라인의 값:False
속성 이름별 파이프라인의 값:False
나머지 인수의 값:False

-InputObject

Specifies ServiceController objects that represent the services to suspend. Enter a variable that contains the objects, or type a command or expression that gets the objects.

매개 변수 속성

형식:

ServiceController[]

Default value:None
와일드카드 지원:False
DontShow:False

매개 변수 집합

InputObject
Position:0
필수:True
파이프라인의 값:True
속성 이름별 파이프라인의 값:False
나머지 인수의 값:False

-Name

Specifies the service names of the services to suspend. Wildcard characters are permitted.

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

매개 변수 속성

형식:

String[]

Default value:None
와일드카드 지원:True
DontShow:False
별칭:ServiceName

매개 변수 집합

Default
Position:0
필수:True
파이프라인의 값:True
속성 이름별 파이프라인의 값:True
나머지 인수의 값:False

-PassThru

Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.

매개 변수 속성

형식:SwitchParameter
Default value:None
와일드카드 지원:False
DontShow:False

매개 변수 집합

(All)
Position:Named
필수:False
파이프라인의 값:False
속성 이름별 파이프라인의 값:False
나머지 인수의 값:False

-WhatIf

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

매개 변수 속성

형식:SwitchParameter
Default value:False
와일드카드 지원:False
DontShow:False
별칭:wi

매개 변수 집합

(All)
Position:Named
필수:False
파이프라인의 값:False
속성 이름별 파이프라인의 값:False
나머지 인수의 값:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

입력

ServiceController

You can pipe a service object to this cmdlet.

String

You can pipe a string that contains a service name to this cmdlet.

출력

None

By default, this cmdlet returns no output.

ServiceController

When you use the PassThru parameter, this cmdlet returns a ServiceController object representing the service.

참고

This cmdlet is only available on Windows platforms.

  • Suspend-Service can control services only when the current user has permission to do this. If a command does not work correctly, you might not have the required permissions.
  • 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 together 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.