Microsoft.Exchange.管理.PowerShell.Admin

发布于 2024-08-06 04:41:50 字数 1147 浏览 2 评论 0原文

我在服务器上使用 Microsoft.Exchange.Management.PowerShell.Admin 时遇到问题。该服务器不是运行 Exchange 2007 的服务器,而是一台远程服务器(位于同一区域)。我不知道如何添加 Powershell 管理单元 - Microsoft.Exchange.Management.PowerShell.Admin。是否可以从 Exchange 2007 服务器获取 dll 文件,并将其复制到运行我的代码的服务器?

有人可以解释一下我需要做什么才能让我的代码运行吗?

我现在遇到的例外是:“没有适用于版本 1 的 Windows PowerShell 管理单元”。这是生成错误的代码:

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);

....

错误来自 PSSnapInfo info = runspaceConf..... 我正在使用.NET 3.5

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

旧时浪漫 2024-08-13 04:41:50

它还取决于代码在 VS 2010 中的编译方式(x86 或 x64)。如果要加载 64 位 Exchange Server 管理单元,则必须使用 x64 进行编译。

您可以使用 $PsVersionTable 检查 PowerShell 是否是版本 2.0(应该是)

It also depends on how the code is compiled in VS 2010 (x86 or x64). If you want to load the 64 Bit Exchange Server Snapin you have to compile with x64.

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

街角迷惘 2024-08-13 04:41:50

我怀疑仅仅获取一个 dll 就足够了。即使只是一个 DLL,管理单元是否支持远程操作?不管怎样,您仍然需要“安装”管理单元以便 PowerShell 能够看到它,例如:

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

如果您想远程执行此操作,并且您碰巧使用的是 PowerShell 2.0,那么请尝试远程处理功能。通过与 Exchange 服务器的远程会话运行管理单元可能会更好。

I doubt that it is sufficient to just grab the one dll. And even if it is just the one DLL, will the snapin support remote operations? Eithe way, you still need to "install" the snapin so that PowerShell sees it e.g.:

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. It would probably be better to run the snapin via a remote session to the Exchange server.

橪书 2024-08-13 04:41:50

我相信 Exchange 2007 管理单元是一个 32 位 DLL。我不是专业程序员,但是尝试将您的程序创建为 32 位应用程序怎么样?

我想如果您将应用程序构建为 32 位,那么它将使用 32 位 PowerShell 引擎,并且能够正确加载管理单元。

现在,我不建议尝试将 DLL 复制到其他服务器。您应该在开发应用程序的服务器上安装 Exchange 管理工具。

希望这有帮助...如果没有,请在下面发表评论。

I believe the Exchange 2007 snapin is a 32-bit DLL. I'm not a professional programmer, but how about trying to create your program as a 32-bit app?

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.

Now, I'd not recommend trying to copy the DLL to other servers. You should be installing the Exchange admin tools on the server where you're developing your app.

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

摘星┃星的人 2024-08-13 04:41:50

对此感到严重困惑。

安装了 Exchange 2007 SP2,并表示它支持 PowerShell v2.0,但事实并非如此。

仍然显示为 PSVersion 1.0 而不是 2.0,如下所示:

名称:microsoft.exchange.management.powershell.admin
PS版本:1.0
描述 : Exchange Server 的管理任务

Seriously confused by this.

Exchange 2007 SP2 installed, says it has PowerShell v2.0 support, but this is NOT TRUE.

Still shows up as a PSVersion 1.0 and not 2.0 look below:

Name : microsoft.exchange.management.powershell.admin
PSVersion : 1.0
Description : Admin Tasks for the Exchange Server

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文