Calling PowerShell From C#
问题 I am using System.Management.Automation DLL which allows me to call PowerShell within my C# application like so: PowerShell.Create().AddScript("Get-Process").Invoke(); What I am trying to do is call PowerShell but supply the input list. For example, in: 1, 2, 3 | ForEach-Object { $_ * 2 } I am trying to supply the left hand side 1, 2, 3 when invoking: // powershell is a PowerShell Object powershell.Invoke(new [] { 1, 2, 3 }); However this does not work. The workaround I came up with was using