I am trying to run EMC commands in C #. I run this from my personal computer on which the exchange management tools are installed.
Our exchange servers work with them for 2007.
The fact is that when I start Powershell or EMC, I need to start as another user with permissions to the Exchange 2007 server, since my individual profile does not have these permissions.
As they say, this is my code that I ran on my personal computer:
RunspaceConfiguration config = RunspaceConfiguration.Create(); PSSnapInException snapEx = null; PSSnapInInfo info = config.AddPSSnapIn("Microsoft.Exchange.Management.Powershell.Admin", out snapEx); Runspace runspace = RunspaceFactory.CreateRunspace(config); runspace.Open(); Command createCMD = new Command("Get-Mailbox ID"); Pipeline pipe = runspace.CreatePipeline(); pipe.Commands.Add(createCMD); Collection<PSObject> results = pipe.Invoke();
The error I am getting is:
The Windows PowerShell Microsoft.Exchange.Management.Powershell.Admin snap-in is not installed on this computer.
I get it when I try to add Microsoft.Exchange.Management.Powershell.Admin snapIn.
I feel this has something to do with my permissions for my individual profile, but I'm not quite sure. If it's true, how can I fix it.
EDIT
The reason I say this seems to be right, because I can open powershell and add snapin. However, when I run a command, such as get-mailboxstatistics myUserId , it gives the error message MyServer\MyStorageGroup . However, when I shift-rightCLick and act as another user and use the credentials of my Exchange admin account, I can execute these commands.
source share