【问题标题】:Connect to Office 365 powershell is failing when password begins with blank space当密码以空格开头时,连接到 Office 365 powershell 失败
【发布时间】:2020-04-12 00:27:31
【问题描述】:

我正在尝试使用用户名和密码通过脚本连接到 PowerShell。当密码以空格开头时 passwordherebeginwithspace,认证失败。

会话创建行如下:

$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $credential -Authentication Basic -AllowRedirection -ErrorAction Stop;

错误:

警告:您的连接已重定向到以下 URI: "https://ps.outlook.com/PowerShell-LiveID?PSVersion=5.1.17763.771" New-PSSession : [ps.outlook.com] 连接到远程服务器 ps.outlook.com 失败并显示以下错误消息:访问权限为 拒绝。

【问题讨论】:

  • 我假设您正在使用 Get-Credential cmdlet 填充 $credential 变量?
  • 是的。它适用于 office 365 登录等。但不适用于 powershell

标签: powershell office365


【解决方案1】:

根据Office 365 Password Policy,云用户密码中不允许有空格。

这是我过去遇到的情况,服务的一部分可以正常工作(例如 Outlook),而另一部分会失败(例如 Sharepoint)。该要求并不总是严格执行。它可能因设置密码的方法而异(Web 登录表单与使用 PowerShell 分配的管理员)。

【讨论】:

  • 非常感谢!甚至我也感到困惑,因为相同的密码适用于 Office 365 登录、Outlook 登录。
猜你喜欢
  • 1970-01-01
  • 2012-04-27
  • 2020-10-24
  • 2014-03-10
  • 1970-01-01
  • 2018-06-09
  • 2015-08-15
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多