如何连接到 Exchange Online PowerShell 模块

正在连接到 Exchange Online PowerShell 模块

通过 PowerShell 管理您的 Exchange 环境可能令人生畏,尤其是在本地和云端环境之间切换时。本文揭示了该过程,提供逐步说明以安装和导入 Exchange Online PowerShell 模块,确保在 Microsoft 365 和 Exchange Online 环境中实现无缝连接和管理。

如何连接到 Exchange Online PowerShell 模块

第 1 步:安装 Exchange Online PowerShell 模块

  • 设置执行策略: This configures PowerShell to allow scripts to run only if they are locally created or digitally signed by a trusted publisher.
    Set-ExecutionPolicy RemoteSigned
  • 安装模块: Install Exchange Online PowerShell from the PowerShell Gallery.
    Install-Module -Name ExchangeOnlineManagement
  • 验证安装: Learn which version of the module has been installed and where it's installed.
    Get-InstalledModule -Name ExchangeOnlineManagement

第 2 步:加载 Exchange Online PowerShell 模块

  • Open a PowerShell window and load the module by running this script:
    Import-Module ExchangeOnlineManagement

第 3 步:连接到 Exchange Online PowerShell 模块

  • 使用多因素身份验证 (MFA) 连接: Connect to Exchange Online PowerShell using MFA.
    Connect-ExchangeOnline -UserPrincipalName
  • 不使用 MFA 连接: Use the Credential parameter instead of the UserPrincipalName parameter to connect without MFA.
    Connect-ExchangeOnline -Credential (-GetCredential)

第 4 步:导入用于本地 Exchange Server 的 Exchange 模块

  • For Exchange Server 2013, 2016, or 2019:
    Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn
  • For Exchange Server 2010:
    Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
  • For Exchange Server 2007:
    Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin

支持的参数

下表包含可与 Connect-ExchangeOnline cmdlet 一起使用的某些参数,以适应不同的身份验证方法、环境和场景。

参数 描述
-UserPrincipalName 指定用于连接到 Exchange Online 的帐户的用户主体名称 (UPN)。
- Credential 提供用于身份验证的 PSCredential 对象,通常用于非 MFA 帐户。
-AccessToken 允许使用 OAuth 2.0 访问令牌进行连接。
-CertificateFilePath 提供用于基于证书身份验证的证书文件路径。
-AppId 指定仅应用程序身份验证场景的应用程序(客户端)ID。
-ExchangeEnvironmentName 指定要连接的 Microsoft 365 环境。

使用 PowerShell 进行 Exchange 管理的限制

虽然 PowerShell 脚本是 Exchange 管理的基础,但使用 PowerShell 管理不断增长的 Active Directory 和 Exchange 环境可能导致显著瓶颈。以下是其限制:

  • 陡峭的学习曲线: PowerShell 脚本需要深入了解 cmdlet、参数和语法。
  • 有限的审计和跟踪: 除非明确编写脚本并与外部日志系统集成,否则 PowerShell 本身不提供详细的审计日志或变更跟踪。
  • 缺乏直观界面: PowerShell 缺乏直观的界面,使得即使是基本任务也复杂且耗时。

ADManager Plus 是一款具备 Exchange 管理 和报告功能的 IGA 解决方案,可帮助您克服这些限制,仅需几次点击即可轻松管理和报告您的 Exchange 环境。

为什么选择 ADManager Plus 而非 PowerShell 进行 Exchange 管理?

ADManager Plus 相较于原生 PowerShell 脚本提供了显著优势,使其成为 IT 管理员的首选。

  1. 全方位、无脚本、统一控制台: 与 PowerShell 不同,ADManager Plus 使您能够通过直观界面管理和报告 Active Directory、Microsoft 365、Exchange Server、Google Workspace 等多平台。
  2. 针对平台的管理和报告: ADManager Plus 为每个平台提供完整的专用功能套件。
    • Exchange Server 管理与报告: 轻松创建、修改、迁移、删除和恢复 Exchange 邮箱。应用策略并管理 OWA、OMA 和 ActiveSync 等功能。获取内置的分发列表成员、启用邮箱的用户、启用邮件的组等报告。
    • Microsoft 365 管理与报告: 批量创建 Microsoft 365 用户帐户,使用预定义操作管理许可证、组、联系人和 Exchange Online 邮箱。通过详细报告了解已授权用户、非活跃用户和动态分发组的情况。
  3. 强大的自动化: 通过简单配置自动执行关键任务,如用户配置、过期帐户清理和 Microsoft 365 许可证管理。使用可定制的多级审批工作流简化操作,确保责任明确并减少人工错误。
  4. 安全的细粒度委派: 创建自定义帮助台角色,将特定的管理和报告操作委派给技术人员或非管理员用户,而无需提升其本地 AD 权限。

使用 ADManager Plus 克服 PowerShell 挑战

常见问题解答

  1. 如何使用 PowerShell 连接到 Exchange Online?

    要连接到 Exchange Online,通常需要先安装 ExchangeOnlineManagement 模块,然后使用 Connect-ExchangeOnline cmdlet 及您的 UserPrincipalName 进行连接。

  2. 我可以对 Exchange 2013 和 2016 使用相同的 PowerShell 模块吗?

    可以,您可以使用 Add-PSSnapin cmdlet 导入 Exchange 2013 和 2016 的 snap-in。

  3. 如何断开 Exchange Online PowerShell 连接?

    您可以使用 Disconnect-ExchangeOnline cmdlet 断开连接。

  4. 为什么导入 Exchange Online 模块时会遇到错误?

    这可能是由于权限不足、PowerShell 版本过旧或执行策略限制。尝试以管理员身份运行 PowerShell,并在连接 Exchange Online 前将执行策略设置为 RemoteSigned。

 
  • 连接到 Exchange Online PowerShell 模块
  • 如何连接到 Exchange Online PowerShell 模块
  • 支持的参数
  • 使用 PowerShell 进行 Exchange 管理的限制
  • 为什么选择 ADManager Plus 而不是 PowerShell 来管理 Exchange
Active Directory管理与报告的一站式解决方案
电子邮件下载链接 Email the ADManager Plus download link