Configuring Exchange Virtual Directories

Below is a script designed to aid admins with setting External URLs on exchange server. Currently this is an initial version with no features or frills. It simply builds External URL Configuration cmdlets base on server name and root URL.

You’ll note that this script is much shorter than other versions out there. This is because I am using an array of hash tables to store and access the unique portions of the URLs. A counter lets the script cycle through each VDir to generate and run the necessary commands. Note: version 1 doesn’t include the Powershell URL, since that one uses HTTP instead of HTTPS.

One last thing to note is that this onlt works on Exchange 2016 due to the removal of the RPC endpoint in IIS.

 

$url = "https://mail.domain.prod/"
$server = "servername"
$vdirs = @{
cmd =@("owa","webservices","mapi","oab","activesync")
url =@("owa","ews/Exchange.asmx","mapi","oab","Microsoft-Server-ActiveSync")
}
$i=0
while($i -lt 6){
$newurl = "get-" + $vdirs.cmd[$i] + "virtualdirectory -server " +$server + " | set-" + $vdirs.cmd[$i] +"virtualdirectory -externalurl " + $url + $vdirs.url[$i] + "-force $true"
write-host setting URL for vdirs.cmd[$i]
Invoke-expression $newurl
$i++
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.