Contact Info

Crumbtrail » Administration » Powershell » Powershell 1.0 » Stop-Service

Stop-Service - Powershell 1.0 CmdLet

Microsoft Windows PowerShell is a command-line shell and scripting tool based on the Microsoft .NET Framework. It is designed for system administrators, engineers and developers to control and automate the administration of Windows and applications.

More than hundred command-line tools (so called "cmdlets") can be used to perform system administration tasks and Windows Management Instrumentation (WMI). These cmdlets are easy to use, with standard naming conventions and common parameters, and standard tools for piping, sorting, filtering, and formatting data and objects.


Stop a running service


-name string
       The service names to be stopped.
   -displayName string
       The display names to be stopped, wildcards are permitted.

   -inputObject ServiceController
       Stop the services represented by ServiceController.
       Enter a command, expression or variable contains the objects.

   -include string
       Stop only the specified services. qualifies the Name parameter.
       Wildcards , such as "s*" are permitted.

   -exclude string
       Omit the specified services e.g. "*SS64*"
       this only works when the path includes a wildcard character.

       Override restrictions that prevent the command from succeeding, apart
       from security settings. e.g. -Force will stop a service
       that has dependent services.

        Pass the object created by Stop-Service along the pipeline. 

       Describe what would happen if you executed the command without
       actually executing the command.
       Prompt for confirmation before executing the command.

       -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutVariable.

Stop the Performance Logs and Alerts (SysmonLog) service on the local computer.:

PS C:\>stop-service sysmonlog

Use -force to stop a service that has dependent services, when doing this it is best to first list all the dependant services with Get-Service:

PS C:\>get-service iisadmin | format-list -property name, dependentservices
PS C:\>stop-service iisadmin -force -confirm