Summary
- Start Windows Service
- Stop Windows Service
- Restart Windows Service
- Start, Stop and Restart Service in Remote Computer
- List all Windows Services and its Running Status
Start Windows Service using Powershell
You can start a windows service by using Start-Service cmdlet.
Start-Service <service-name> -PassThru
The parameter -PassThru force the command to wait until service started and displays its running status.
Start-Service "RemoteRegistry" -PassThru
If you want to start a service by its display name, you can do it by simply passing display name with the argument -displayname.
Start-Service -displayname <service-display-name> -PassThru
Below command start the RemoteRegistry service by using its -display name “Remote Registry”.
Start-Service -displayname "Remote Registry" -PassThru
Stop Windows Service using Powershell
You can stop a windows service by using the Powershell cmdlet Stop-Service.
Stop-Service <service-name> -PassThru
Here, The parameter -PassThru force the command to wait until service stopped and displays status.
Stop-Service "RemoteRegistry" -PassThru
Restart Windows Service using Powershell
You can restart a windows service by using the Powershell cmdlet Restart-Service.
Restart-Service <service-name> -PassThru
Here, the parameter -PassThru force the command to wait until the service get restarted completed and displays its running status.
Restart-Service "RemoteRegistry" -PassThru
Start, Stop and Restart Windows Service in Remote Computer
If you want to start, stop and restart a service in Remote machine, you can do it by using two Powershell cmdlets Get-Service and any one of the manage service cmdlet. First, you can get the windows service object from remote computer by using Get-Service cmdlet and you can do any action like Start,Stop and Restart by using Remote Service object.
Get-Service <service-name> -ComputerName <remote-pc-name> | Start-Service -PassThru
Start the RemoteRegistry service in Win7-PC by using below command:
Get-Service "RemoteRegistry" -ComputerName "Win7-PC" | Start-Service -PassThru
Restart the RemoteRegistry service in Win7-PC by using below command:
Get-Service "RemoteRegistry" -ComputerName "Win7-PC" | Restart-Service -PassThru
Stop the RemoteRegistry service in Win7-PC by using below command:
Get-Service "RemoteRegistry" -ComputerName "Win7-PC" | Stop-Service -PassThru