• Uncategorized
  • 0

PowerShell function to resolve Exchange Hybrid domains

Here’s a PowerShell function to check if the DNS-record exist for those domains we choose in Exchange Hybrid Configuration Wizard.

Save the file as .csv and make the header Domain,Value (comma-separated).

Example (CSV-file):



PowerShell function:

    Check if TXT-record exist for Exchange Hybrid domains
    Save txt-file from Exchange Hybrid Configuration Wizard, make it comma-seperated CSV-file and 
    then use this PowerShell function to check if the DNS-record exist. 
    The fucntion can ask, or
    Resolve-ExchangeHybridDNSRecord -CSVFile C:\Temp\Domains.csv -DNSServer
    Resolve-ExchangeHybridDNSRecord -CSVFile C:\Temp\Domains.csv -DNSServer
    Location to CSV file containing the headers 'Domain' and 'Value' from Exchange Hybrid Configuration Wizard
    External DNS service used to query DNS-records, use between, or
    Writes to console (Write-Host)
    Version:        1.0
    Author:         Pierre Thoor, AddPro AB
    Creation Date:  2018-06-27
    Purpose/Change: Initial script development
function Resolve-ExchangeHybridDNSRecord{
        HelpMessage="Path to CSV file containing Domain and Value header", 
        If(Test-Path $_ -PathType "Leaf"){$true}else{Throw "Invalid path given: $_"}

        HelpMessage="External DNS service to query, choose between | |",

    $DNSRecords = Import-Csv $CSVFile -Delimiter ","

    $DNSRecords | ForEach-Object{
        $ResolveDNS = Resolve-DnsName -Name $_.Domain -Type TXT -Server $DNSServer -ErrorAction SilentlyContinue
        if($ResolveDNS.Strings -eq $_.Value){
            Write-Host "DNS-Record exist for" $_.Domain -ForegroundColor Green
            Write-Host " -> Error for" $_.Domain "<- " -ForegroundColor Red


You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: