troubleshooting Question

Getting "Access is denied" when excuting powershell script.

Avatar of Mike
MikeFlag for United States of America asked on
Microsoft ApplicationsMicrosoft DevelopmentMicrosoft Server Apps
2 Comments1 Solution808 ViewsLast Modified:
I attempting to create a power shell script to stop and start a service on stand alone server (.i.e not part a AD domain) but I keep getting the following error "Get-WmiObject : Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) . I checked and the RPC is running but it does not allow me to change the services status... Does anybody have an idea what I am missing.
$computername = "ServeName"
$service = "ServiceName"

(gwmi win32_service -computername $computername -filter "name='$service'").stopservice()  
 (gwmi win32_service -computername $computername -filter "name='$service'").startservice()
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros