Call a specific version of PowerShell from C#
I'm trying to use the Get-VM Cmdlet called from C# on a Hyper-V host. Obviously, the according PowerShell module Hyper-V has to be imported first. The import fails, however - apparently because the module is supported only on PowerShell 3.0 (at least that's what I figure from this article ). The PowerShell used by System.Management.Automation seems to be version 2.0, though. InitialSessionState iss = InitialSessionState.CreateDefault(); iss.ImportPSModule(new string[] { "Hyper-V" }); Runspace runSpace = RunspaceFactory.CreateRunspace(iss); runSpace.Open(); foreach (var err in (ArrayList