0

I'm trying to migrate an application from .NET 4.5 to .NET Core 2.1.

This application is using the System.Management.Automation dll to execute powershell commands and scripts. I need to use some PSSnapin from a SDK and i don't know if i can get those functionalities in .NET Core 2.1

I tried using an InitialSessionState to import my snapins but it returned a TypeLoadException for type PSSnapin. https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.runspaces.initialsessionstate.importpssnapin?view=pscore-6.2.0#System_Management_Automation_Runspaces_InitialSessionState_ImportPSSnapIn_System_String_System_Management_Automation_Runspaces_PSSnapInException__

So can i load my PSSnapin using PowershellCore in C# ? Or can i access System.Management.Automation from .NET Core 2.1 to keep calling the scripts ?

dotdiego
  • 157
  • 3
  • 14

1 Answers1

0

I finally gave up loading my snapins in net core.
I'm now using a Remote Runspace on a server that has powershell 5.1 and the snapins i want to use.

dotdiego
  • 157
  • 3
  • 14