I want to execute command in remote machine with administrator privileges from python scriot written in local machine any command is there

using method as,
c=Client(hostname, username=“”, password=",ssl=False)
print(c.execute_ps(command))

Please provide a lot more detail about what are you trying to do.
For example where did you get Client from, which package?
What OS are you interested in?
Both the local OS and the remote OS.
Why would you set ssl=False? That seems like a security risk.

I want to list down all GPO’s from remote machine to local machine

from pypsrp.client import Client
from ldap3 import Connection, Server

#want to list all gpo’s of remote machine

command=“powershell -command get-gpo -all”
c= Client(hostname, username=“”, password=“”,ssl=False)
print(c.execute_cmd(c))

error is,

get-gpo : Access is denied. (Exception from HRESULT: 0x80070005
(E_ACCESSDENIED))
At line:1 char:1

  • get-gpo -all
  •   + CategoryInfo          : NotSpecified: (:) [Get-GPO], UnauthorizedAccessE 
     xception
      + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.Gro
     upPolicy.Commands.GetGpoCommand

I guess from reading the pypsrp PyPI page that you are running on a linux machine and trying to run powershell commands on a set of Windows machines.

This is a setup a know next to nothing about.

But I do know that you will need the username and password for an account that is allowed to login to the Windows hosts.

Ask your windows admin what username you need to use.

Oh and I would be shocked it ssl=False was supported.
The examples do not include that keyword parameter.

Hey Scott,

I am executing this script from windows(local) to windows server(remote).
for remote server, user is having admin privileges

So could you please help to find a way to resolve this issue

This is not really a question about python, but about Windows and Powershell.
I personal do not know enough to helpo you.

In your position I would look for help using powershell to access a remote machine.
And also talk to the authors of pypsrp, do they have any user support?

Try raising an Issues · jborean93/pypsrp · GitHub maybe?