I'm having troubles using the Microsoft.Exchange.Management.PowerShell.Admin on a server. The server is not the one running Exchange 2007, it's a remote server (in the same zone). I can't figure out how to add the Snapin for Powershell - Microsoft.Exchange.Management.PowerShell.Admin. Is it possible to just get the dll file from the Exchange 2007 server, and copy it to the server where my code is running?
Can someone please explain what I need to do to get my code running?
The exception that i'm getting now is: "No Windows PowerShell Snap-ins are available for version 1". This is the code that generates the error:
public void CreateMailBox(User user)
{
//Create a runspace for your cmdlets to run and include the Exchange Management SnapIn...
RunspaceConfiguration runspaceConf = RunspaceConfiguration.Create();
PSSnapInException PSException = null;
PSSnapInInfo info = runspaceConf.AddPSSnapIn("Microsoft.Exchange.Management.PowerShell.Admin", out PSException);
Runspace runspace = RunspaceFactory.CreateRunspace(runspaceConf);
runspace.Open();
Pipeline pipeline = runspace.CreatePipeline();
Command command = new Command("New-Mailbox");
command.Parameters.Add("Name", user.UserName);
....
The error is coming on the line with PSSnapInfo info = runspaceConf..... I'm using .NET 3.5