I am having problems using Microsoft.Exchange.Management.PowerShell.Admin on the server. The server is not the one running Exchange 2007, it is a remote server (in the same zone). I can't figure out how to add Snapin for Powershell - Microsoft.Exchange.Management.PowerShell.Admin. Can I just get the DLL file from the Exchange 2007 server and copy it to the server where my code works?
Can someone explain what I need to do to run my code?
The exception that I get now is: "There is no Windows PowerShell snap-in 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 goes along the line with PSSnapInfo info = runningpaceConf ..... I am using .NET 3.5
source share