4

I migrated from .NET Framework 4.8 to .NET 6.

System.Management.Automation.PowerShell.Create();

now returns null.

Packages

Is there a new package i need to reference or other solution?

3
  • This is happening because of a version of miss-match. Can please share the exception if any Commented Jan 18, 2022 at 20:30
  • Nevermind stackoverflow.com/questions/51733481/… helped me. Commented Jan 18, 2022 at 20:34
  • 1
    At a minimum you need System.Management.Automation (everything contained in that package is also included in the SDK) Commented Jan 18, 2022 at 20:37

1 Answer 1

3

Removing the old References and adding the NuGet package Microsoft.PowerShell.SDK solved this issue.

Sign up to request clarification or add additional context in comments.

3 Comments

An overview of all PowerShell SDK-related packages can be found in this answer.
Note, however, that the package you mention is for creating stand-alone PowerShell (Core) applications, whereas the PowerShellStandard.Library package is for creating modules and PowerShell hosts that run from within PowerShell - and the latter package is designed to work in PowerShell (Core) sessions too.
I wasted time trying to use the powershellstandard.library. Because the SDK was so large and I was skeered to use it. This article may help: stackoverflow.com/questions/51733481/…

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.