JanivZ JanivZ - 1 year ago 277
C# Question

running powershell from .net core

Is there a way to run powershell scripts from .net-core ?

I'm trying to run a powershell script in a new .net core 'website\api'.
From what I can tell in order to run powershell on .net we need to add the

System.Management.Automation namespace.

This isn't possible for .net core ( or I haven't found the appropriate way to add it).
There are a couple of nuget packages which are also aimed at adding this dll to project but those aren't compatible with .net core either.
Is there a way to do this on .net core ?
Here are some links I've tried but none of them are .net core specific:


Referencing system.management.automation.dll in Visual Studio


Thanks !

Answer Source

The official answer is that running PowerShell Core from your own application is currently not supported. Probably the biggest issue is that .Net Core is missing AppDomain.GetAssemblies(), which might be fixed in .Net Core 1.2.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download