PowerShell on remote server 2016 error: Cannot open Service Control Manager on computer 'xxx.xxx.xxx.xxx'. This operation might require other privileges.[0]

Mohamed Sayed 1 Reputation point
2021-06-02T11:27:15.687+00:00

Hi Gurus,
I have a PowerShell script used to stop/start services on a remote 2016 server running from another 2016 server.
I enabled PS remoting, enabled File and Printer sharing in Firewall, I have a domain user which has Domain Admin permission.

When I run the script from Task Scheduler using that account, I get the below error:
Cannot open Service Control Manager on computer 'xxx.xxx.xxx.xxx'. This operation might require other privileges.[0]

When I use Administrators group in the Task Scheduler, it works fine when triggered manually (and of course it doesnt trigger automatically because I cannot change the checkbox for "Run whether User is logged in or not").

When I run the script from PowerShell As Administrator, it works fine too.
When I run the script manually from PowerShell using the domain account (Run As Different user), it works fine as well.

What could be wrong with Task Scheduler?

Windows for business | Windows Server | User experience | Other
{count} votes

7 answers

Sort by: Most helpful
  1. Andy YOU 3,076 Reputation points
    2021-07-02T01:55:56.807+00:00

    HI MohamedSayed-4462,

    Is there anything I can help you?


  2. Alexis Anselmi Fernandez 0 Reputation points
    2023-09-15T10:50:55.8933333+00:00

    Hi there, I had the same issue and this was my solution.

    Obtain credentials:

     $pw = convertto-securestring -AsPlainText -Force -String <insert pw here>
     $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist "Domain\User",$pw
     $session = new-pssession -computername <computer> -credential $cred
    

    Then invoke the command

    Invoke-Command -Session $session -ScriptBlock {get-service -name "YOUR_SERVICE_NAME"}
    
    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.