I am invoking a powershell script using C# in .NET and the System.Management.Automation package.
It has been working with PowerCLI in my scripts for a long time, however when i add the command Get-ContentLibrary i constantly get the error An error occurred while trying to get content libraries by names. I do not get this error if I execute the same powershell-function directly from the ISE.
I have tried to find any differences between the ISE PS environment and the C# PS environment. They use the same powershell version (5.1.14393.4583), same PowerCLI version (12.4.0) etc.
Is there something I am not aware of? I know this question is entering .NET domain, but as I have spent many hours on the issue now any help is greatly appreciated!
Thanks for the reply, @LucD !
Yes, If i just run $test = Get-ContentLibrary i get the same error Get-ContentLibrary An error occurred while trying to get content libraries by names. This seems really odd?
Here's the inner exception: "Could not retrieve handler field info from the HttpClient .net type."
I have attempted to completely reinstall PowerCLI and its sub-components, without any luck.