Microsoft.Exchange.Management.PowerShell.Admin

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

+1
source share
4 answers

It also depends on how the code compiles in VS 2010 (x86 or x64). If you want to download Snapin for a 64-bit Exchange server, you must compile it using x64.

You can use $ PsVersionTable to check if PowerShell is version 2.0 (it should)

+1
source

I doubt it is enough to just take one dll. And even if it's just one DLL, will snapin support remote operations? Eithe way, you still need to β€œinstall” snapin so that PowerShell sees it, for example:

 PS> $snapinPath = 'Microsoft.Exchange.Management.PowerShell.Admin.dll' PS> C:\Windows\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe /i $snapinPath 

If you want to do this remotely and you are probably using PowerShell 2.0, try using the remote access features. It would probably be better to start snapin through a remote session on the Exchange server.

0
source

I believe snapin Exchange 2007 is a 32-bit DLL. I'm not a professional programmer, but what about creating your program as a 32-bit application?

I think that if you create your application as 32-bit, it will use the 32-bit PowerShell engine and will be able to load snapin correctly.

Now I do not recommend copying DLLs to other servers. You must install the Exchange administration tools on the server on which you are developing your application.

Hope this helps ... If not, write a comment below.

0
source

Seriously confuses this.

Exchange 2007 Service Pack 2 (SP2) is installed, it supports PowerShell v2.0, but it is NOT TRUE.

Shown as PSVersion 1.0, not 2.0 below:

Name: microsoft.exchange.management.powershell.admin PSVersion: 1.0 Description: Administrator tasks for Exchange Server

0
source

Source: https://habr.com/ru/post/958890/


All Articles