I'm developing a program that uses System.Management.Automation library so I can create an instance of PowerShell. Something like:
using (var instance = System.Management.Automation.PowerShell.Create())
{
// do something
}
In order to avoid forcing the user to have PowerShell v3 installed, I'm using System.Management.Automation Nuget package version 6.3.9600.17400. When testing on my machine, I'm getting the following error:
An error occurred while attempting to load the system Windows PowerShell snap-ins. Please contact Microsoft Customer Support Services. ---> System.Management.Automation.PSArgumentException: Unable to access Windows PowerShell PowerShellEngine registry information.
I'm lost on this. Right now, I'm trying to install PowerShell v3 on my machine to see if it works. I really thought having the package would work. Is there something I can do?
Thanks in advance
Well, I gave up using PowerShell v3 and I'm using v1 instead.
So I referenced System.Management.Automation.dll from: C:\Windows\assembly\GAC_MSIL\System.Management.Automation.
I've been able to use the needed Snap-Ins so far