当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] 使用 MFA 的 Exchange Online PowerShell

作者:精品下载站 日期:2024-12-14 20:54:27 浏览:14 分类:玩电脑

使用 MFA 的 Exchange Online PowerShell


[玩转系统] 使用 MFA 的 Exchange Online PowerShell

如果您一直在使用 PowerShell 管理您的 Office 365 邮箱,那么您很可能一直在使用远程 PowerShell 会话进行连接,类似于以下内容:

$Credentials = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $Credentials -Authentication Basic -AllowRedirection
Import-PSSession $Session -DisableNameChecking

如果您按照 Microsoft 的建议在管理员帐户上启用 MFA(多重身份验证),您现在将面临以下令人讨厌的输出:

New-PSSession : [outlook.office365.com] Connecting to remote server outlook.office365.com failed with the following error message : 
Access is denied. For more information, see the about_Remote_Troubleshooting Help topic.
At line:2 char:12
+ $Session = New-PSSession -ConfigurationName Microsoft.Exchange -Conne ...
+            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotingTransportException
    + FullyQualifiedErrorId : AccessDenied,PSSessionOpenFailed
Import-PSSession : Cannot validate argument on parameter 'Session'. The argument is null. Provide a valid value for the argument,
and then try running the command again.
At line:3 char:18
+ Import-PSSession $Session -DisableNameChecking
+                  ~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Import-PSSession], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.ImportPSSessionCommand

显然,在启用多因素身份验证的情况下对 Exchange Online 进行远程 PowerShell 根本行不通……

Exchange Online PowerShell V2 模块可助您一臂之力

要使用启用了 MFA 的管理员帐户针对 Exchange Online 运行 PowerShell 脚本,您需要 ExchangeOnlineManagement 模块, 又名 EXO V2

使用以下命令从 PSGallery 安装模块:

Install-Module ExchangeOnlineManagement

安装模块后,您可以使用以下命令连接到 Exchange Online:

Connect-ExchangeOnline

ExchangeOnlineManagement 模块具有所有旧的熟悉的 Exchange CmdLets,因此基本上您的旧脚本将保持功能。

但是,一些命令已升级并且可以使用 EXO 前缀使用。此信息总结在以下输出中:

----------------------------------------------------------------------------
We have released new management cmdlets which are faster and more reliable.

|--------------------------------------------------------------------------|
|    Old Cmdlets                    |    New/Reliable/Faster Cmdlets       |
|--------------------------------------------------------------------------|
|    Get-CASMailbox                 |    Get-EXOCASMailbox                 |
|    Get-Mailbox                    |    Get-EXOMailbox                    |
|    Get-MailboxFolderPermission    |    Get-EXOMailboxFolderPermission    |
|    Get-MailboxFolderStatistics    |    Get-EXOMailboxFolderStatistics    |
|    Get-MailboxPermission          |    Get-EXOMailboxPermission          |
|    Get-MailboxStatistics          |    Get-EXOMailboxStatistics          |
|    Get-MobileDeviceStatistics     |    Get-EXOMobileDeviceStatistics     |
|    Get-Recipient                  |    Get-EXORecipient                  |
|    Get-RecipientPermission        |    Get-EXORecipientPermission        |
|--------------------------------------------------------------------------|

To get additional information, run: Get-Help Connect-ExchangeOnline
Please send your feedback and suggestions to [email protected]
----------------------------------------------------------------------------

看到此输出后,Connect-ExchangeOnline cmdlet 将立即向您显示 MFA 感知的现代身份验证登录提示:

[玩转系统] 使用 MFA 的 Exchange Online PowerShell

[玩转系统] 使用 MFA 的 Exchange Online PowerShell

[玩转系统] 使用 MFA 的 Exchange Online PowerShell

成功输入您的凭据和 MFA 密码后,您就可以开始摇滚了!

从 AD 用户属性管理 Office 365 邮箱

Easy365Manager 是 Active Directory 用户和计算机的一个小型管理单元,允许您直接从 AD 用户属性管理 Office 365 许可证和邮箱。

许多通常需要 PowerShell 脚本编写的任务现在可以直接在用户属性中执行。

例如,通过直接在 AD 中委派日历权限,您可以节省大量时间并减少不便:

Easy365Manager 支持 MFA 身份验证并安全地缓存您的 Office 365 令牌,因此您无需在每次使用 Active Directory 时重新进行身份验证。

Easy365Manager 只需几分钟即可在任何具有 RSAT/ADUC 的计算机上安装和配置,并且真正节省时间。

您甚至可以删除最后一个本地 Exchange Server。

有关功能的完整列表,请阅读此内容。

在此下载功能齐全的 30 天试用版。

概括

ExchangeOnlineModule 于 2019 年底发布,目前仍处于预览阶段。但由于管理员的多重身份验证变得越来越流行,您应该考虑迁移到这个新模块

事实上,Exchange Online 上的基本身份验证支持将于 2020 年 10 月 13 日结束。因此,在此日期之后,即使禁用了 MFA,您也将无法使用标准 Exchange PowerShell 远程处理。

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯