简体   繁体   English

Microsoft.Exchange.Management.PowerShell.Admin

[英]Microsoft.Exchange.Management.PowerShell.Admin

I'm having troubles using the Microsoft.Exchange.Management.PowerShell.Admin on a server. 我在服务器上使用Microsoft.Exchange.Management.PowerShell.Admin时遇到麻烦。 The server is not the one running Exchange 2007, it's a remote server (in the same zone). 该服务器不是运行Exchange 2007的服务器,而是一台远程服务器(在同一区域中)。 I can't figure out how to add the Snapin for Powershell - Microsoft.Exchange.Management.PowerShell.Admin. 我不知道如何为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? 是否可以仅从Exchange 2007服务器获取dll文件,然后将其复制到运行我的代码的服务器上?

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". 我现在得到的例外是:“版本1没有Windows PowerShell管理单元”。 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 该错误即将与PSSnapInfo info = runspaceConf .....一起使用。我正在使用.NET 3.5

It also depends on how the code is compiled in VS 2010 (x86 or x64). 它还取决于在VS 2010(x86或x64)中如何编译代码。 If you want to load the 64 Bit Exchange Server Snapin you have to compile with x64. 如果要加载64位Exchange Server管理单元,则必须使用x64进行编译。

You can use $PsVersionTable to check if the PowerShell is version 2.0 (it should) 您可以使用$ PsVersionTable来检查PowerShell是否为2.0版(应该)

I doubt that it is sufficient to just grab the one dll. 我怀疑仅获取一个dll是否足够。 And even if it is just the one DLL, will the snapin support remote operations? 即使只是一个DLL,该管理单元是否也支持远程操作? Eithe way, you still need to "install" the snapin so that PowerShell sees it eg: 否则,您仍然需要“安装”该管理单元,以便PowerShell可以看到它,例如:

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 happen to be using PowerShell 2.0 then try out the remoting features. 如果您想远程执行此操作, 并且碰巧正在使用PowerShell 2.0,请尝试使用远程处理功能。 It would probably be better to run the snapin via a remote session to the Exchange server. 通过与Exchange服务器的远程会话运行管理单元可能会更好。

I believe the Exchange 2007 snapin is a 32-bit DLL. 我相信Exchange 2007管理单元是32位DLL。 I'm not a professional programmer, but how about trying to create your program as a 32-bit app? 我不是专业的程序员,但是如何尝试将您的程序创建为32位应用程序呢?

I'm thinking if you build your app as 32-bit, then it will use the 32-bit PowerShell engine, and be able to load the snapin properly. 我在想,如果您将应用程序构建为32位,则它将使用32位PowerShell引擎,并能够正确加载管理单元。

Now, I'd not recommend trying to copy the DLL to other servers. 现在,我不建议您尝试将DLL复制到其他服务器。 You should be installing the Exchange admin tools on the server where you're developing your app. 您应该在要开发应用程序的服务器上安装Exchange管理工具。

Hope this helps... If not, post a comment below. 希望这会有所帮助...如果没有,请在下面发表评论。

Seriously confused by this. 对此感到严重困惑。

Exchange 2007 SP2 installed, says it has PowerShell v2.0 support, but this is NOT TRUE. 安装了Exchange 2007 SP2,说它具有PowerShell v2.0支持,但这不是真的。

Still shows up as a PSVersion 1.0 and not 2.0 look below: 仍然显示为PSVersion 1.0,而不是2.0,如下所示:

Name : microsoft.exchange.management.powershell.admin PSVersion : 1.0 Description : Admin Tasks for the Exchange Server 名称:microsoft.exchange.management.powershell.admin PSVersion:1.0说明:Exchange Server的管理任务

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Exchange 在线管理 Powershell 模块和证书 Oauth - Exchange Online Management Powershell module and Certificate Oauth 在C#中连接到Microsoft Exchange PowerShell - Connect to Microsoft Exchange PowerShell within C# Powershell通用会话并在Exchange远程管理会话中导入此会话 - Powershell generic session and import this session in Exchange remote management session System.Management.Automation.Powershell RunAs管理员 - System.Management.Automation.Powershell RunAs Admin C#已连接到Powershell,但是我需要连接到Exchange命令行管理程序 - C# Connected to Powershell, but I need connect to Exchange Management Shell 从C#到Microsoft Exchange 2013命令的PowerShell缓慢执行 - Slow PowerShell execution of Microsoft Exchange 2013 commands from c# Microsoft的Exchange Powershell架构的URL不再有效 - Microsoft's url for the Exchange powershell schema is not valid anymore 为什么相同的脚本在 Exchange Management Shell 2010 中有效,但不能通过 C# 与 Powershell 和 Exchange Connection - Why does the same script work in Exchange Management Shell 2010 but not through C# with Powershell and Exchange Connection Exchange和PowerShell - Exchange and PowerShell C#Powershell-Exchange管理{“值不能为空。\\ r \\ n参数名称:serverSettings”} - C# Powershell - Exchange management {“Value cannot be null.\r\nParameter name: serverSettings”}
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM