简体   繁体   English

是否可以从cPython运行PowerShell和Active Directory命令?

[英]Is it possible to run PowerShell and Active Directory commands from cPython?

I have 2 questions about cPython (but not IronPython): 我有2个关于cPython(但不是IronPython)的问题:

  1. Is it possible to run PowerShell commands from cPython? 是否可以从cPython运行PowerShell命令?
  2. Is it possible to run Active Directory commands from cPython? 是否可以从cPython运行Active Directory命令?

Depends what you mean by "run commands". 取决于“运行命令”的含义。

Active directory can be interfaced with via LDAP (with a package like python-ldap) or, if you must, you can always call third party "commands" directly using on of the many process control libs for python (like subprocess ) 可以通过LDAP(使用python-ldap之类的包)通过LDAP与Active Directory进行接口,或者,如果必须的话,您始终可以使用许多python的过程控制库中的on(例如subprocess )直接调用第三方“命令”。

In [4]: subprocess.call('hostname')
rafael-imac.h.xxxxx.zzz
Out[4]: 0

I hope this helps. 我希望这有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM