1
下面是我的Iron Python腳本,它可以很好地處理所有系統級命令(get-process等),但我想添加MS-Exchange管理單元以調用交換命令。有人能幫我嗎 ?如何使用鐵蟒添加交換管理單元
DEF了RunScript(腳本):
runspace = RunspaceFactory.CreateRunspace()
runspace.Open()
pipeline = runspace.CreatePipeline()
cache = System.IO.Path.GetTempFileName()
pipeline.Commands.AddScript(script)
pipeline.Commands.Add("Out-String")
results = pipeline.Invoke()
pickled = []
for thing in results:
pickled.append(thing.ToString())
return pickled
感謝 Susant
它是powershell命令「Add-PSSnapin」。我如何在Iron Python中做什麼?什麼是可用的等效功能?將Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin添加到運行空間 – Susant
'腳本'也是powershell代碼,對不對?所以你可以添加一個調用來在其頂部添加Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin。 –
用另一個選項更新了我的答案。 –