Exchange Powershell - 如何从内部脚本调用 Exchange 2010 模块?

发布于 2024-11-08 05:07:22 字数 321 浏览 0 评论 0原文

我正在编写一个脚本,该脚本可以使用 AD 和 Exchange 执行许多操作,并且刚刚到达 GUI 的部分,我需要在其中开始使用 Exchange,但看不到可以手动指定包含 Exchange 模块的位置。我熟悉的正常过程是导入模块活动目录,但导入模块交换不起作用。

我执行了 Get-Module -ListAvailable |选择名称,但看不到任何表示 Exchange 的内容。但是,Exchange 命令行管理程序已加载到我正在使用的 Exchange 服务器上。

有谁知道如何在我的脚本中包含 Exchange 2010 模块,以便我可以在内部使用特定于交换的 cmdlet?蒂亚...

I'm writing a script that does a number of things with AD and Exchange and just got to the part of the GUI where I need to start working with Exchange but don't see where I can manually specify to include the Exchange module. The normal process I'm familiar with is import-module activedirectory but import-module exchange doesn't work.

I performed a Get-Module -ListAvailable | Select Name, and don't see anything indicating Exchange. However, the Exchange Management Shell IS loaded on the Exchange server I'm working on.

Does anyone know how to include the Exchange 2010 module in my script so I can use the exchange-specific cmdlets internally? TIA...

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

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

发布评论

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

评论(3

我喜欢麦丽素 2024-11-15 05:07:22

你可以这样做:

add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010

并且大部分都可以工作(尽管 MS 支持会告诉你不支持这样做,因为它绕过了 RBAC)。

我发现一些 cmdlet(特别是启用/禁用 UMmailbox)存在问题,无法仅在加载的管理单元中使用。

在 Exchange 2010 中,它们基本上不支持在实际 EMS shell 的隐式远程处理环境之外使用 Powershell。

You can do this:

add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010

and most of it will work (although MS support will tell you that doing this is not supported because it bypasses RBAC).

I've seen issues with some cmdlets (specifically enable/disable UMmailbox) not working with just the snapin loaded.

In Exchange 2010, they basically don't support using Powershell outside of the the implicit remoting environment of an actual EMS shell.

§对你不离不弃 2024-11-15 05:07:22

我知道这是一个老问题,但我没有添加显然不受支持的管理单元,而是查看了 EMS 快捷方式属性并复制了这些命令。

完整的快捷方式目标是:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noexit -command ". 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto"

因此,我将以下内容放在脚本的开头,它似乎按预期运行:

. 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'
Connect-ExchangeServer -auto

注意:

  • 必须在 64 位 PS 中运行
  • 这是在仅安装了管理工具的服务器上进行测试的。它自动连接到我们现有的 Exchange 基础设施。
  • 尚未进行广泛的测试,因此我不知道此方法是否可行。如果遇到任何问题,我将编辑这篇文章。

I know this is an old question, but rather than adding the snapin which is apparently unsupported, I just looked at the EMS shortcut properties and copied those commands.

The full shortcut target is:

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noexit -command ". 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto"

So I put the following at the start of my script and it seemed to function as expected:

. 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'
Connect-ExchangeServer -auto

Notes:

  • Has to be run in 64bit PS
  • This was tested on a server with just the Management Tools installed. It automatically connected to our existing Exchange infrastructure.
  • No extensive testing has been done, so I do not know if this method is viable. I will edit this post if I run into any issues.
太傻旳人生 2024-11-15 05:07:22

import-module Microsoft.Exchange.Management.PowerShell.E2010a尝试使用一些实现,例如:

$exchangeser = "MTLServer01"
$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionURI http://${exchangeserver}/powershell/ -Authentication kerberos
import-PSSession $session 

add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010

import-module Microsoft.Exchange.Management.PowerShell.E2010aTry with some implementation like:

$exchangeser = "MTLServer01"
$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionURI http://${exchangeserver}/powershell/ -Authentication kerberos
import-PSSession $session 

or

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