Skip to main content

Stop-ServiceAndDependencies

SYNOPSISโ€‹

Stop Windows service and its dependencies.

SYNTAXโ€‹

Stop-ServiceAndDependencies [-Name] <String> [[-ComputerName] <String>] [-SkipServiceExistsTest]
[-SkipDependentServices] [[-PendingStatusWait] <TimeSpan>] [-PassThru] [[-ContinueOnError] <Boolean>]
[<CommonParameters>]

DESCRIPTIONโ€‹

Stop Windows service and its dependencies.

EXAMPLESโ€‹

EXAMPLE 1โ€‹

Stop-ServiceAndDependencies -Name 'wuauserv'

PARAMETERSโ€‹

-Nameโ€‹

Specify the name of the service.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ComputerNameโ€‹

Specify the name of the computer. Default is: the local computer.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 2
Default value: $env:ComputerName
Accept pipeline input: False
Accept wildcard characters: False

-SkipServiceExistsTestโ€‹

Choose to skip the test to check whether or not the service exists if it was already done outside of this function.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-SkipDependentServicesโ€‹

Choose to skip checking for and stopping dependent services. Default is: $false.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-PendingStatusWaitโ€‹

The amount of time to wait for a service to get out of a pending state before continuing. Default is 60 seconds.

Type: TimeSpan
Parameter Sets: (All)
Aliases:

Required: False
Position: 3
Default value: (New-TimeSpan -Seconds 60)
Accept pipeline input: False
Accept wildcard characters: False

-PassThruโ€‹

Return the System.ServiceProcess.ServiceController service object.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-ContinueOnErrorโ€‹

Continue if an error is encountered. Default is: $true.

Type: Boolean
Parameter Sets: (All)
Aliases:

Required: False
Position: 4
Default value: True
Accept pipeline input: False
Accept wildcard characters: False

CommonParametersโ€‹

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

INPUTSโ€‹

Noneโ€‹

You cannot pipe objects to this function.โ€‹

OUTPUTSโ€‹

System.ServiceProcess.ServiceController.โ€‹

Returns the service object.โ€‹

NOTESโ€‹

https://psappdeploytoolkit.com