Saturday, August 29, 2015

PowerShell - Start-Service : Service 'x' cannot be started due to the following error: Cannot open x service on computer '.'

If you want to start a service through PowerShell you might get this error:

Start-Service YOUR_SERVICE_NAME

Start-Service : Service 'x' cannot be started due to the following error: Cannot open
x service on computer '.'.
At line:1 char:72
+ ... here-Object {$_.DisplayName -eq "x"} | Start-Service
+                                                             ~~~~~~~~~~~~~
    + CategoryInfo          : OpenError: (System.ServiceProcess.ServiceController:ServiceController) [Start-Service],
   ServiceCommandException
    + FullyQualifiedErrorId : CouldNotStartService,Microsoft.PowerShell.Commands.StartServiceCommand

We get this error because we are not running the PowerShell with Administrative privileges. Just right click on PowerShell and then click 'Run as administrator'. You will get your cmdlet worked.

Similarly you might have to do the same thing for following service commands:
  • New-Service   
  • Restart-Service
  • Resume-Service
  • Set-Service   
  • Start-Service 
  • Stop-Service  
  • Suspend-Service

1 comment: