【发布时间】:2020-11-06 03:08:12
【问题描述】:
我在尝试使用自动化帐户中的服务帐户连接到 Exchange Online 时收到此错误。我认为问题也可能是我的 $credential 变量没有传递到我的 $session 变量中,但我想不出任何原因会发生这种情况。
错误:
New-PSSession : [outlook.office365.com] 连接到远程服务器 outlook.office365.com 失败,出现以下问题 错误消息:访问被拒绝。有关详细信息,请参阅 about_Remote_Troubleshooting 帮助主题。 在 line:5 char:12
- $session = New-PSSession -ConfigurationName Microsoft.Exchange -Conne ...
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~- CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotingTransportException
- FullyQualifiedErrorId : AccessDenied,PSSessionOpenFailed Import-PSSession:无法验证参数“会话”的参数。参数为空。为 参数,然后尝试再次运行该命令。 在 line:6 char:42
- Import-Module (Import-PSSession -Session $session -DisableNameCheckin ...
-
~~~~~~~~
脚本:
参数 ( [字符串] $Employee = "" ) $credential = Get-AutomationPSCredential -Name 'admin@crafthub.onmicrosoft.com' $session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri 'https://outlook.office365.com/powershell-liveid/' -Credential $credential -Authentication Basic -AllowRedirection 导入模块(导入 PSSession -Session $session -DisableNameChecking -AllowClobber)-全局 $mailbox = 获取邮箱 -Identity $Employee 写输出$邮箱
我们将非常感谢您的帮助
【问题讨论】:
标签: azure exchange-server azure-automation