python - Pywinrm and Active Directory PowerShell cmdlets -


i encounter weird issue python code uses pywinrm module. let me explain bit. have linux server launch following python script:

import winrm  """create security group""" s = winrm.session('https://servername:5986/wsman',     auth=(none, none), transport='kerberos',     server_cert_validation='ignore')  name = "test" path = "ou=security groups,dc=test,dc=org"  ps_command = 'new-adgroup -name "{0}"  -groupscope universal  -groupcategory security  -path "{1}" -server ldap.ubisoft.org'.format(name, path)  r = s.run_ps(ps_command)  if r.status_code == 0 :     print(r.std_out.decode('utf-8')) else:     print(r.std_err('utf-8')) 

this 1 connect on https listener of windows server (not dc) launch command of group creation.

when launch ad cmdlet directly on windows server, works , security group created within ad. via script, have following response:

$ python3 test_winrm.py new-adgroup : unable contact server. may because server not exist, down, or not have active directory web services running. @ line:1 char:1 + new-adgroup -name "test" -groupscope universal -groupcategory security -path "o ... +  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~ + categoryinfo          : resourceunavailable: (:) [new-adgroup], adserver downexception + fullyqualifiederrorid : activedirectoryserver:0,microsoft.activedirector y.management.commands.newadgroup 

i want notice if replace current powershell command basic 1 (for instance, creation of folder on windows server), works.

so works on windows server locally not ad cmdlets if rsat installed... have previous experience on topic?

thanks help.


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -