Calling PowerShell From C#

后端 未结 2 1870
猫巷女王i
猫巷女王i 2020-12-06 07:20

I am using System.Management.Automation DLL which allows me to call PowerShell within my C# application like so:

PowerShell.Create().AddScript(\         


        
2条回答
  •  攒了一身酷
    2020-12-06 07:38

    I have done my research and PowerShell.Invoke( IEnumerable ) will set the InputObject of the first command in the list. Therefore instead of setting InputObject on inputCmd above, we can instead pass it through the Invoke method. We still need the first ForEach-Object call to pass the input array to.

提交回复
热议问题