`PowerShell.Create()` returning null


Added reference: PowerShellStandard.Library

Repro inside a default .net-core project:

I’ve tried it with or without the using block, but I end up with the same result: the Create method is not creating a PowerShell object, but it’s also not throwing an exception.

Is this a common issue with the PowerShell .net-standard library? Is there a workaround or another way to solve my problem?

Additional info, this is also happening with the RunspaceFactory class CreateRunspace method as I was exploring a workaround with managing runspaces myself.


Looking through the source of the PowerShellStandard Library I noticed the following lines:

Those will always return the default of the sealed PowerShell class and that will always be null.

This makes it that PowerShell isn’t (fully) supported in PowerShellStandard Library 5.1.

Same is for RunspaceFactory.CreateRunspace.


PowerShell.Create() returning null by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply