繁体   English   中英

使用访问令牌通过 Powershell 连接到 Exchange Online

[英]Connect to Exchange Online with Powershell using Access Token

我已经从 Azure AD 获得了访问令牌和刷新令牌。 我需要使用访问令牌/刷新令牌从 powershell 连接到各种 O365 服务。 有人可以指导我如何继续在线连接到交换服务器。

有没有其他方法可以使用现代身份验证在线连接到交换服务器。 我使用的是 ExchangeOnlineManagement 2.0.3 版本。 我根据下面列出的博客的建议使用了下面的代码片段。 我收到类似“密码长度超过 256”的错误。

https://o365reports.com/2020/07/04/modern-auth-and-unattended-scripts-in-exchange-online-powershell-v2/

https://www.michev.info/Blog/Post/1771/hacking-your-way-around-modern-authentication-and-the-powershell-modules-for-office-365

我们需要使流程自动化,但无法使用访问令牌连接到交易所。

$AccessToken = <access-token-value>
$Authorization = "Bearer {0} " -f $AccessToken
$Password = ConvertTo-SecureString -AsPlainText $Authorization -Force
$UserCredential = New-Object System.Management.Automation.PSCredential("<upn-value>", $Password)
Connect-ExchangeOnline -Credential $UserCredential -ShowProgress $true

错误消息:我收到密码长度超过 256 个字符的错误消息。

抱歉耽搁了。

我明白你的要求。 我知道使用带有基本身份验证的New-PSSession很快就会被弃用,因此您正在寻找替代方案。

但目前不支持使用访问令牌连接到 Exchange Online,原因是AADSTS50052: The password entered exceeds the maximum length of '256'. . 我认为你不必为此担心。 到那时,微软应该能够覆盖 V1 模块所具有的所有功能。

在此处查看类似问题。

我找到了解决方案。 参考下面的文章,我们需要安装ExchangeOnlineManagement 2.0.3版本并使用证书连接。 请按照以下帖子中提到的步骤进行操作。

https://www.quadrotech-it.com/blog/certificate-based-authentication-for-exchange-online-remote-powershell/

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM