I need to execute the following powershell command in C# :
get-netconnectionprofile
if i run the command from PowerShell it returns one record :
but if I run the following code it returns an empty list.
public void CheckWLANNetWork()
{
using (PowerShell PowerShellInstance = PowerShell.Create())
{
// use "AddScript" to add the contents of a script file to the end of the execution pipeline.
// use "AddCommand" to add individual commands/cmdlets to the end of the execution pipeline.
PowerShellInstance.AddCommand("get-netconnectionprofile"); //
var test = PowerShellInstance.Invoke(); //here test it is an empty list
}
}
Although, if I run the above method with "Get-Process", for example, it runs just fine. I am running a X86 app, and my pc is x64. I cannot run my application on x64 due to other tools which runs only on x86. Is there a solution here?
EDIT:
As suggested, I called PowerShellInstance.Streams.Error;
The error returned is : "Provider load failure".