【问题标题】:How to use a Python output in a powershell script?如何在 powershell 脚本中使用 Python 输出?
【发布时间】:2021-04-30 08:14:09
【问题描述】:

我这周开始学习 Python,我正在尝试自动将新用户添加到 Active Directory 和 Office 365 上。

我已设法使用客户端和机器人将用户添加到 AD,并且还使用另一个脚本为 Powershell 生成正确的 New-MsolUser 语法。

如何让 Python 打开Powershell 并运行“o365command”的输出?

每次执行此操作时我还需要连接到租户,因此我是否还需要将其合并到脚本中?

如果需要,很高兴展示我的代码。

【问题讨论】:

标签: python powershell office365


【解决方案1】:

如果您将 Python 的输出作为 JSON 提供给文件,则 PowerShell 可以直接导入该文件。请参阅 ConvertFrom-Json (ConvertFrom-Json)。

关于从 Python 运行 PowerShell,请看:Running an outside program (executable) in Python? 这不是我曾经尝试过的东西,但祝你好运。

【讨论】:

    猜你喜欢
    • 2014-03-23
    • 2011-06-07
    • 1970-01-01
    • 2017-12-10
    • 1970-01-01
    • 1970-01-01
    • 2015-06-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多