I put together a simple script that will add an Accepted Domain in Exchange 2019 from the Exchange Management Shell (EMS) instead of using the GUI.

The script does require manual input of the following fields:

  • DomainName – This is the domain you want to add to Exchange, for example: tlab.net
  • DomainType – Has 3 options: Authoritative (Default), InternalRelay and ExternalRelay

I have added comments to make it easier to understand, once you have filled in the fields, this is what the output will be:

Get accepted domain script

If you want to view this or create it in the Exchange Admin Center you can do so as well. Here is the script that was used, feel free to modify it to suite your needs:

# Import the Exchange module
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn

# Specify the parameters for the new accepted domain
$domainName = "tlab.net"
$domainType = "Authoritative"  # Change to "InternalRelay" or "ExternalRelay" if needed

# Create the new accepted domain
New-AcceptedDomain -Name $domainName -DomainName $domainName -DomainType $domainType

# Display confirmation message
Write-Host "Accepted domain '$domainName' has been created with type '$domainType'."

If your domain has Group Policies (GPO’s) that block scripts saved from executing, you can run this from PowerShell ISE as well, the module for Exchange Server 2019 is imported/added at the beginning of the script to make it easier, the output is the same as shown below:

Exchange 2019:- add an accepted domain with powershell

Hope it helps.


    Discover more from Everything-PowerShell

    Subscribe now to keep reading and get access to the full archive.

    Continue reading