Problem invoking powershell in C#

  • Thread starter Thread starter tjntjntjn
  • Start date Start date
T

tjntjntjn

Guest
Get-PrintConfiguration works fine in PowerShell command line. But I cant use invoke in C#.

C# code snip:

-------------------------

PowerShell ps = PowerShell.Create();

ps.AddCommand("Get-PrintConfiguration").AddParameter("PrinterName","printer");

foreach (PSObject obj in ps.Invoke())

{

......................

}

-------------------------

Error: "An error occurred while performing the specified operation"

I dont have other problems with using Powershell from C#


Any idea on how to use Get-PrintConfiguration in C#?

Continue reading...
 
Back
Top