I am struggling getting Exchange mManagement Shell commands to run in my C# code. Here' the problem.
I have access to a test Exchange Server running Exchange 2010.
I have run my Exchange Mgmt Shell commands directly on the server inside the Exchange Mgmt Shell Simple Example: get-mailbox
I created a console app to run my PS commands
I placed the exe file on the Exchange Server and tried to run it
I get an error on the PSSnapInInfo info = rsConfig.AddPSSnapIn line of code:
//Creating and Opening a Runspace
RunspaceConfiguration rsConfig = RunspaceConfiguration.Create();
PSSnapInException snapInException = null;
PSSnapInInfo info = rsConfig.AddPSSnapIn("Microsoft.Exchange.Management.PowerShell.Admin", out snapInException);
Runspace myRunSpace = RunspaceFactory.CreateRunspace(rsConfig);
myRunSpace.Open();
There is another post with this exact same issue but no real answer so I am starting this one.
The problem is simple. I can't add the snapin called "Microsoft.Exchange.Management.PowerShell.Admin". All the documentation I read on the net says this is the command that will work. In fact I found this post, http://msdn.microsoft.com/en-us/library/bb332449(EXCHG.80).aspx that is very straight forward and seems very simple. Did "Microsoft.Exchange.Management.PowerShell.Admin" go away in Exchange 2010? Is there another snapin I should be referencing? This should ber really simple but I can't get past this error.
BTW, the error I get is: "No snap-ins have been registered for Windows PowerShell version 2."
Any help would be appreciated.