Learn about my 2012 Core Survival Guide here.
This module is going to look at how to manage services. The key to using PowerShell to manage any service is to know the exact spelling of the service name.
How to list services
Get-service | Format-table -autosize
The output below show each services status, name and display name.
How to view a single service
You can use the "NAME" of the service to display a single service's information.
Get-service | where name -eq BITS |Format-list
In the output below we use the format-list (or fl) to show all of the service's attributes.
How to start a single service
To start a service there is a simple PowerShell cmdlet called Start-Service. Below I use it to start the BITS service.
Start-Service -name BITS
The output below shows the current status of the service, followed by the command to start the service (in yellow), and followed by a command to confirm the status.
How to stop a service
Stopping a service is easy too. I use the Stop-Service cmdlet below to stop the BITS services.
Stop-Services -name BITS
The output below shows the current status of the service, followed by the command to stop the service, and followed by a command to confirm the status.
How view a Service Startup Type
In order to view the startup type I had to make a WMI call.
Get-wmiobject win32_service | where Name -eq WinRM
In the screen shot below "StartMode" is the startup type of the service and it is set to disabled. There are 3 possible values for this setting Manual, Automatic, and Disabled.
How to change the Service Startup Type
The Set-Service cmdlet has three possible settings for "-StartupType" flag: Automatic, Disabled, and Manual.
Set-Service -name WinRM -StartupType Automatic
The output below shows the current status, followed by the command to disable the WinRM service, and followed by the command to confirm the change.
I hope you found this useful. Please leave me a comment. Let me know if there are any core tasks you would like me to cover.
how do we change the account on the service?