Runspace y powershell personalizado

I'm trying to develop some tool in C# which is using PowerShell. However, I have to use different powershell then this one which is used by default when creating Runspace, I mean this one:


Is it possible to force Runspace to use different (customized) version of powershell?

The problem with the standard version of powershell doesn't have many commands, such like "Open-Device" and "Close-Device".

Gracias de antemano

preguntado el 31 de julio de 12 a las 10:07

1 Respuestas

I think you are missing the difference between the PSH runtime and the host. The host provides services (Write-Host, transscripts, ...) to the runtime. Hence ISE doesn't do transcripts because it doesn't implement that service.

With a runspace you just get the core PSH runtime plus any snapins/modules you load into it. Depending how Open-Device y Close-Device are implemented you might be stuck. If they are implemented by a snapin or module (that your custom host automatically loads) then just load the necessary components. If those cmdlets depend on something the host itself implements then you'll need to look at running a separate process.

(Increasingly having to use a custom host should be seen as poor form as it won't work with jobs, remoting, and (I suspect) workflows.)

Respondido 31 Jul 12, 12:07

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.