I have reviewed the documentation from microsoft and alot of examples but for some reason connecting to a tenant using our admin privs will not connect:
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell-liveid?DelegatedOrg=xxxxx.onmicrosoft.com -Credential $UserCredential -Authentication Basic –AllowRedirection
I have also tried substituting the domain name to outlook.office365.com as well
The error returned is:
New-PSSession : [ps.outlook.com] Processing data from remote server ps.outlook.com failed with the following error message: [AuthZRequestId=477bd052-617e-4e8c-aee9-dxxxxxxxx][FailureCategory=AuthZ-CmdletAccessDeniedException] The operation couldn't be performed because 'xxxxx.onmicrosoft.com\[email protected]' couldn't be found. For more information, see the about_Remote_Troubleshooting Help topic.
I have ensured that the deligated admin account is:
- Global administrator
- Administrative access to companies you support: Yes / Full admin
I have also tried to google up that error, not alot of information. As well this site: https://gcits.com/knowledge-base/ has a tone of examples about this using those examples results in basically the same hang up.
I can however connect and issue the "$customers = Get-MsolPartnerContract -All" and view all the tenants.
Any ideas?
** UPDATE ** code is below as per request. Thanks again!
$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