An Office 365 tenant can contain multiple domains in a verified or unverified state.
This script simply outputs the MX records for each domain that has been verified into a CSV file named after the tenant ID. The CSV file is output to the %temp% by default.
You will need to run the script inside a PowerShell session connected to Office 365.
#This script collects the MX records for all domains which have been verified in an O365 tenant. #Run the script from within an O365 PowerShell session. #Author: Ben Owens #Date: 03/10/2016 $temp = $env:temp $TenantID = Get-MSOLDomain | Where {$_.IsInitial -eq "TRUE"} | Select Name -ExpandProperty Name $Domains = Get-MSOLDomain | Where {$_.Status -eq "Verified"} | Select Name $MXRecords = ForEach ($Domain in $Domains) {Resolve-DnsName -Name $Domain.Name -Type MX | Where {$_.QueryType -eq "MX"}} $MXRecords | Export-CSV "$Temp\$TenantID-mxrecords.csv" -NoTypeInformation $Output = "$Temp\$TenantID-mxrecords.csv" $Output Notepad $Output
Example Output:
0 comments:
Post a comment