I am trying to write a PowerShell script to stop the services on the local computer.
When I run the get-service cmdlet, it works as expected. When I use the stop-service cmdlet, it indicates that no service exists with the specified name. If this is true, then the get-service cmdlet will throw the same error.
Get-Service "Service 1" # Returns Service and status Stop-Service "Service 1" # Throws error below: Stop-Service : Service 'Service 1' cannot be stopped due to the following error: Cannot open Service 1 service on computer '.'.
Is there a trick when using the stop-service cmdlet?
source share