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.

 

[code language=”powershell”]
$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++
}
[/code]

Leave a Reply

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