Calling Powershell from C# (ASP.NET) - pass custom object?
问题 I'm having trouble trying to call a Powershell function from C#. Specifically, I'm getting stuck trying to pass a generic list of Project's to a powershell module function. Here is the code: var script = @". \\server01\Modules\Runspace.ps1; Get-MyCommand"; var allProjects = _pmRepository.GetAllProjects(); using (Runspace runSpace = RunspaceFactory.CreateRunspace()) { runSpace.Open(); PowerShell posh = PowerShell.Create(); posh.Runspace = runSpace; posh.AddScript(script); posh.AddArgument