我已经阅读了Microsoft的文档以及许多示例,但是由于某些原因,使用我们的admin privs连接到租户将无法连接:
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell-liveid?DelegatedOrg=xxxxx.onmicrosoft.com -Credential $UserCredential -Authentication Basic –AllowRedirection
我也尝试过将域名替换为outlook.office365.com
返回的错误是:
New-PSSession:[ps.outlook.com]处理来自远程服务器的数据 ps.outlook.com失败,并显示以下错误消息: [AuthZRequestId = 477bd052-617e-4e8c-aee9-dxxxxxxxx] [FailureCategory = AuthZ-CmdletAccessDeniedException] 无法执行该操作,因为 'xxxxx.onmicrosoft.com \ xxxxxxadmin@xxxxx.onmicrosoft.com'不能为 找到了。有关更多信息,请参见about_Remote_Troubleshooting帮助 主题。
我确保指定的管理员帐户为:
我还尝试过搜索该错误,而不是大量信息。同样,该站点:https://gcits.com/knowledge-base/也提供了一些示例,使用这些示例会导致基本相同的挂断。
但是我可以连接并发出“ $ customers = Get-MsolPartnerContract -All”并查看所有租户。
有什么想法吗?
** UPDATE **代码如下所示(根据要求)。再次感谢!
$credential = Get-Credential Connect-MsolService -Credential $credential $customers = Get-MsolPartnerContract -All Write-Host "Found $($customers.Count) customers for $((Get-MsolCompanyInformation).displayname)." foreach ($customer in $customers) { Write-Host "Connecting to: $($customer.name)" -ForegroundColor Yellow $InitialDomain = Get-MsolDomain -TenantId $customer.TenantId | Where-Object {$_.IsInitial} $DelegatedOrgURL = "https://ps.outlook.com/powershell-liveid?DelegatedOrg=" + $InitialDomain.Name $EXODS = New-PSSession -ConnectionUri $DelegatedOrgURL -Credential $credential -Authentication Basic -ConfigurationName Microsoft.Exchange -AllowRedirection Import-PSSession $EXODS -CommandName Get-CASMailbox, Set-CasMailbox, Get-Casmailboxplan, set-casmailboxplan
答案 0 :(得分:1)
我找到了解决方法
感谢大家的帮助。