| external help file | Microsoft.PowerShell.Commands.Management.dll-Help.xml |
|---|---|
| Locale | en-US |
| Module Name | Microsoft.PowerShell.Management |
| ms.date | 12/12/2022 |
| online version | https://learn.microsoft.com/powershell/module/microsoft.powershell.management/suspend-service?view=powershell-5.1&WT.mc_id=ps-gethelp |
| schema | 2.0.0 |
| title | Suspend-Service |
Suspends (pauses) one or more running services.
Suspend-Service [-InputObject] <ServiceController[]> [-PassThru] [-Include <String[]>] [-Exclude <String[]>]
[-WhatIf] [-Confirm] [<CommonParameters>]
Suspend-Service [-Name] <String[]> [-PassThru] [-Include <String[]>] [-Exclude <String[]>] [-WhatIf] [-Confirm]
[<CommonParameters>]
Suspend-Service [-PassThru] -DisplayName <String[]> [-Include <String[]>] [-Exclude <String[]>] [-WhatIf]
[-Confirm] [<CommonParameters>]
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.
PS C:\> Suspend-Service -DisplayName "Telnet"
This command suspends the Telnet service (Tlntsvr) service on the local computer.
PS C:\> 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.
PS C:\> 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.
PS C:\> 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.
Specifies the display names of the services to be suspended. Wildcard characters are permitted.
Type: System.String[]
Parameter Sets: DisplayName
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: TrueSpecifies 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.
Type: System.String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: TrueSpecifies 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.
Type: System.String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: TrueSpecifies 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.
Type: System.ServiceProcess.ServiceController[]
Parameter Sets: InputObject
Aliases:
Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: FalseSpecifies 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.
Type: System.String[]
Parameter Sets: Default
Aliases: ServiceName
Required: True
Position: 0
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: TrueReturns an object representing the item with which you are working. By default, this cmdlet does not generate any output.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalsePrompts 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: FalseShows what would happen if the cmdlet runs. The cmdlet is not 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: FalseThis cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
You can pipe a service object to this cmdlet.
You can pipe a string that contains a service name to this cmdlet.
By default, this cmdlet returns no output.
When you use the PassThru parameter, this cmdlet returns a ServiceController object representing the service.
Suspend-Servicecan 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-Servicecan suspend only services that support being suspended and resumed. To determine whether a particular service can be suspended, use theGet-Servicecmdlet 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, typeGet-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.