通过委派合作伙伴访问权限从O365跨租户获取MX记录

时间:2020-09-06 12:00:21

标签: azure powershell office365

我正在尝试从O365 / Exchange在线中的所有客户域中检索列表。

当前,我正在使用此脚本检索所有邮箱大小的列表:

    $credential = Get-Credential
    connect-msolservice -Credential $credential
    $clients = Get-MsolPartnerContract -All
    foreach ($client in $clients) { 
    $ClientDomain = Get-MsolDomain -TenantId $client.TenantId | Where-Object {$_.IsInitial -eq $true}
    Write-host "Logging into portal for $($client.Name)"
    $DelegatedOrgURL = "https://ps.outlook.com/powershell-liveid?DelegatedOrg=" + $ClientDomain.Name
    $ExchangeOnlineSession = New-PSSession -ConnectionUri $DelegatedOrgURL -Credential $credential
    -Authentication Basic -ConfigurationName Microsoft.Exchange -AllowRedirection
    Import-PSSession -Session $ExchangeOnlineSession -AllowClobber -DisableNameChecking
    Get-Mailbox | Get-MailboxStatistics | Select-Object DisplayName, IsArchiveMailbox, ItemCount, 
    TotalItemSize | format-table
    Remove-PSSession $ExchangeOnlineSession
    }

我尝试合并

     Get-MxRecordReport -Domain "contoso.com"

     Get-AzureADDomainServiceConfigurationRecord -Name domain.com | ? {$_.RecordType -eq "Mx"} | 
     select MailExchange

但是我似乎无法为所有客户域的MX记录生成一个不错的列表。 任何建议将不胜感激。

0 个答案:

没有答案