Home > Exchange 2007, Exchange 2010, Useful Tools > Exchange 2003, 2007 and 2010 URLs

Exchange 2003, 2007 and 2010 URLs

So I am in the process of rebuilding my Exchange/OCS labs and I plan on probably rebuilding them a few times, so I have been working on a few things to streamline the builds and configuration, one of the tools I have been using over the years was a nice script put together by Stale Hansen and a few merry men. the script when run will present you with a number of options allowing you to set URLs for Exchange 2010, 2007 and the Exchange 2003 legacy URL, simple tasks but it is little tools like this that make my days easier allowing to to spend more time with Call of Duty Smile.

Below is the PowerShell script which can be found on Stale’s blog here http://msunified.net/2010/05/07/script-for-configuring-exchange-2010-internal-and-external-urls/ or a direct link http://msunified.net/exchange-downloads/script-internalexternalurls-ps1/

 

####################################################################################################
# Set-InternalExternalURLs.ps1
#
# v03 May2010 by Ståle Hansen (http://msunified.net)
#
# Idea from MVP’s Anderson Patricio and Pat Richard, script designed for Exchange 2010 prerequisites
# Thanks to Marjus Sirvinsks for adapting the script further
#
####################################################################################################
[System.Console]::ForegroundColor = [System.ConsoleColor]::White
clear-host

    write-host
    write-host Script for setting Internal and External URLs on Exchange 2007/2010
    write-host
    write-host Please choose one of the following:
    write-host
    write-host ‘1) Exchange 2010 Internal URLs’
    write-host ‘2) Exchange 2010 External URLs’
    write-host ‘3) Exchange 2007 Internal URLs’
    write-host ‘4) Exchange 2007 External URLs’
    write-host ‘5) Exchange 2003 Legacy URL’
    write-host ‘6) List Current URL Config’
    write-host ‘7) Cancel’ -ForegroundColor Red
    write-host
    $opt = Read-Host "Select an option [1-7]"

switch ($opt)    {

1{
# Set Exchange 2010 Internal URLs using Client Access Arrays in correct sites

Write-Warning "Exchange 2010 Internal URLs requires that a ClientAccessArray is created"

Foreach($Server in Get-ClientAccessServer | Get-ExchangeServer | where-object {$_.AdminDisplayVersion.Major -eq 14}){
$CASserver = $Server.Identity
$ADsite = Get-ExchangeServer $Server
$site = $ADsite.site
$urlpath = Get-ClientAccessArray | where-object {$_.site -eq $site}
$casarray = $urlpath.fqdn

Write-Host
Write-Host "Found Exchange 2010 Client Access Server " -NoNewLine
Write-Host $CASserver -NoNewLine -Foregroundcolor Green
Write-Host " in ADsite " -NoNewLine
Write-Host $site -Foregroundcolor Green

Write-Host "Client Access Array is resolved to " -NoNewLine
Write-Host $casarray -NoNewLine -foregroundcolor Green
Write-Host " in ADsite " -NoNewLine
Write-Host $site -foregroundcolor Green
Write-Host "Will use " -NoNewLine
Write-Host https://$casarray -NoNewLine -foregroundcolor Green
Write-Host " as InternalUrl on this server"

}

Write-Host
Write-Host "Press " -NoNewLine
Write-Host "Enter" -NoNewLine -foregroundcolor Green
Write-Host " to continue, or " -NoNewLine
Write-Host "CTR+C " -NoNewLine -foregroundcolor Red
Write-Host "to cancel"
[System.Console]::ForegroundColor = [System.ConsoleColor]::Gray
Read-Host
[System.Console]::ForegroundColor = [System.ConsoleColor]::White

Foreach($Server in Get-ClientAccessServer | Get-ExchangeServer | where-object {$_.AdminDisplayVersion.Major -eq 14}){
$CASserver = $Server.Identity
$ADsite = Get-ExchangeServer $Server
$site = $ADsite.site
$urlpath = Get-ClientAccessArray | where-object {$_.site -eq $site}
$casarray = $urlpath.fqdn

Get-AutodiscoverVirtualDirectory -Server $CASserver | Set-AutodiscoverVirtualDirectory –InternalUrl "https://$casarray/Autodiscover/Autodiscover.xml"
Get-ClientAccessServer -Identity $CASserver | Set-ClientAccessServer –AutodiscoverServiceInternalUri "https://$casarray/Autodiscover/Autodiscover.xml"
Get-WebservicesVirtualDirectory -Server $CASserver | Set-WebservicesVirtualDirectory –InternalUrl "https://$casarray/Ews/Exchange.asmx"
Get-OabVirtualDirectory -Server $CASserver | Set-OabVirtualDirectory –InternalUrl "https://$casarray/Oab"
Get-OwaVirtualDirectory -Server $CASserver | Set-OwaVirtualDirectory –InternalUrl "https://$casarray/Owa"
Get-EcpVirtualDirectory -Server $CASserver | Set-EcpVirtualDirectory –InternalUrl "https://$casarray/Ecp"
Get-ActiveSyncVirtualDirectory -Server $CASserver | Set-ActiveSyncVirtualDirectory -InternalUrl "https://$casarray/Microsoft-Server-ActiveSync"
}

#Get commands to doublecheck the config
[System.Console]::ForegroundColor = [System.ConsoleColor]::White

Get-AutodiscoverVirtualDirectory | ft Identity,InternalUrl
Get-ClientAccessServer | ft Identity,AutodiscoverServiceInternalUri
Get-WebservicesVirtualDirectory | ft Identity,InternalUrl
Get-OabVirtualDirectory | ft Identity,InternalUrl
Get-OwaVirtualDirectory | ft Identity,InternalUrl
Get-EcpVirtualDirectory | ft Identity,InternalUrl
Get-ActiveSyncVirtualDirectory | ft Identity,InternalUrl

[System.Console]::ForegroundColor = [System.ConsoleColor]::Gray

}

2{
# Set external URL on all Exchange 2010 Client Access Servers using input

Foreach($Server in Get-ClientAccessServer | Get-ExchangeServer | where-object {$_.AdminDisplayVersion.Major -eq 14}){
$CASserver = $Server.Identity
$ADsite = Get-ExchangeServer $Server
$site = $ADsite.site

Write-Host
Write-Host "Found Exchange 2010 Client Access Server " -NoNewLine
Write-Host $CASserver -NoNewLine -Foregroundcolor Green
Write-Host " in ADsite " -NoNewLine
Write-Host $site -Foregroundcolor Green
Write-Host

}

$urlpath = Read-Host "Type external FQDN for Exchange 2010 Client Access"
Write-Host "Will set ExternalUrl as " -NoNewLine
Write-Host "https://$urlpath/" -NoNewLine -foregroundcolor Green
Write-Host " on all Exchange 2010 Client Access Servers"

Write-Host
Write-Host "Press " -NoNewLine
Write-Host "Enter" -NoNewLine -foregroundcolor Green
Write-Host " to continue, or " -NoNewLine
Write-Host "CTR+C " -NoNewLine -foregroundcolor Red
Write-Host "to cancel"
[System.Console]::ForegroundColor = [System.ConsoleColor]::Gray
Read-Host
[System.Console]::ForegroundColor = [System.ConsoleColor]::White

Foreach($Server in Get-ClientAccessServer | Get-ExchangeServer | where-object {$_.AdminDisplayVersion.Major -eq 14}){
$CASserver = $Server.Identity

Get-AutodiscoverVirtualDirectory -Server $CASserver | Set-AutodiscoverVirtualDirectory –ExternalUrl "https://$urlpath/Autodiscover/Autodiscover.xml"
Get-webservicesVirtualDirectory -Identity $CASserver | Set-webservicesVirtualDirectory –ExternalUrl "https://$urlpath/Ews/Exchange.asmx"
Get-OabVirtualDirectory -Server $CASserver | Set-OabVirtualDirectory –ExternalUrl "https://$urlpath/Oab"
Get-OwaVirtualDirectory -Server $CASserver | Set-OwaVirtualDirectory –ExternalUrl "https://$urlpath/Owa"
Get-EcpVirtualDirectory -Server $CASserver | Set-EcpVirtualDirectory –ExternalUrl "https://$urlpath/Ecp"
Get-ActiveSyncVirtualDirectory -Server $CASserver | Set-ActiveSyncVirtualDirectory -ExternalUrl "https://$urlpath/Microsoft-Server-ActiveSync"
}

#Get commands to doublecheck the config
[System.Console]::ForegroundColor = [System.ConsoleColor]::White

Get-AutodiscoverVirtualDirectory | ft Identity,ExternalUrl
Get-webservicesVirtualDirectory | ft Identity,ExternalUrl
Get-OabVirtualDirectory | ft Identity,ExternalUrl
Get-OwaVirtualDirectory | ft Identity,ExternalUrl
Get-EcpVirtualDirectory | ft Identity,ExternalUrl
Get-ActiveSyncVirtualDirectory | ft Identity,ExternalUrl

[System.Console]::ForegroundColor = [System.ConsoleColor]::Gray

}

3{
# Set Exchange 2007 Internal URLs using input

Foreach($Server in Get-ClientAccessServer | Get-ExchangeServer | where-object {$_.AdminDisplayVersion.Major -lt 14}){
$CASserver = $Server.Identity
$ADsite = Get-ExchangeServer $Server
$site = $ADsite.site

Write-Host
Write-Host "Found Exchange 2007 Client Access Server " -NoNewLine
Write-Host $CASserver -NoNewLine -Foregroundcolor Green
Write-Host " in ADsite " -NoNewLine
Write-Host $site -Foregroundcolor Green
Write-Host

}

Write-Host "Type internal FQDN for Exchange 2007 Client Access"
Write-Host "Please type http:// or https:// in front: " -NoNewLine -foregroundcolor Yellow
$urlpath = Read-Host
Write-Host
Write-Host "Will set InternalUrl as " -NoNewLine
Write-Host "$urlpath/" -NoNewLine -foregroundcolor Green
Write-Host " on all Exchange 2007 Client Access Servers"

Write-Host
Write-Host "Press " -NoNewLine
Write-Host "Enter" -NoNewLine -foregroundcolor Green
Write-Host " to continue, or " -NoNewLine
Write-Host "CTR+C " -NoNewLine -foregroundcolor Red
Write-Host "to cancel"
[System.Console]::ForegroundColor = [System.ConsoleColor]::Gray
Read-Host
[System.Console]::ForegroundColor = [System.ConsoleColor]::White

Foreach($Server in Get-ClientAccessServer | Get-ExchangeServer | where-object {$_.AdminDisplayVersion.Major -lt 14}){
$CASserver = $Server.Identity

Get-AutodiscoverVirtualDirectory -Server $CASserver | Set-AutodiscoverVirtualDirectory –InternalUrl "$urlpath/Autodiscover/Autodiscover.xml"
Get-ClientAccessServer -Identity $CASserver | Set-ClientAccessServer –AutodiscoverServiceInternalUri "$urlpath/Autodiscover/Autodiscover.xml"
Get-WebservicesVirtualDirectory -Server $CASserver | Set-WebservicesVirtualDirectory –InternalUrl "$urlpath/Ews/Exchange.asmx"
Get-OabVirtualDirectory -Server $CASserver | Set-OabVirtualDirectory –InternalUrl "$urlpath/Oab"
Get-OwaVirtualDirectory -Identity "$CASserver\OWA (Default Web site)"  | Set-OwaVirtualDirectory –InternalUrl "$urlpath/Owa"
Get-ActiveSyncVirtualDirectory -Server $CASserver | Set-ActiveSyncVirtualDirectory -InternalUrl "$urlpath/Microsoft-Server-ActiveSync"
}

#Get commands to doublecheck the config
[System.Console]::ForegroundColor = [System.ConsoleColor]::White

Get-AutodiscoverVirtualDirectory | ft Identity,InternalUrl
Get-ClientAccessServer | ft Identity,AutodiscoverServiceInternalUri
Get-WebservicesVirtualDirectory | ft Identity,InternalUrl
Get-OabVirtualDirectory | ft Identity,InternalUrl
Get-OwaVirtualDirectory | ft Identity,InternalUrl
Get-ActiveSyncVirtualDirectory | ft Identity,InternalUrl

[System.Console]::ForegroundColor = [System.ConsoleColor]::Gray

}

4{
# Set external URL on Exchange 2007 Client Access Servers using input

Foreach($Server in Get-ClientAccessServer | Get-ExchangeServer | where-object {$_.AdminDisplayVersion.Major -lt 14}){
$CASserver = $Server.Identity
$ADsite = Get-ExchangeServer $Server
$site = $ADsite.site

Write-Host
Write-Host "Found Exchange 2007 Client Access Server " -NoNewLine
Write-Host $CASserver -NoNewLine -Foregroundcolor Green
Write-Host " in ADsite " -NoNewLine
Write-Host $site -Foregroundcolor Green
Write-Host
}

$urlpath = Read-Host "Type external FQDN for Client Access"
Write-Host "Will set ExternalUrl as " -NoNewLine
Write-Host "https://$urlpath/" -NoNewLine -foregroundcolor Green
Write-Host " on all Exchange 2007 Client Access Servers"

Write-Host
Write-Host "Press " -NoNewLine
Write-Host "Enter" -NoNewLine -foregroundcolor Green
Write-Host " to continue, or " -NoNewLine
Write-Host "CTR+C " -NoNewLine -foregroundcolor Red
Write-Host "to cancel"
[System.Console]::ForegroundColor = [System.ConsoleColor]::Gray
Read-Host
[System.Console]::ForegroundColor = [System.ConsoleColor]::White

Foreach($Server in Get-ClientAccessServer | Get-ExchangeServer | where-object {$_.AdminDisplayVersion.Major -lt 14}){
$CASserver = $Server.Identity

Get-AutodiscoverVirtualDirectory -Server $CASserver | Set-AutodiscoverVirtualDirectory –ExternalUrl "https://$urlpath/Autodiscover/Autodiscover.xml"
Get-webservicesVirtualDirectory -Server $CASserver | Set-webservicesVirtualDirectory –ExternalUrl "https://$urlpath/Ews/Exchange.asmx"
Get-OabVirtualDirectory -Server $CASserver | Set-OabVirtualDirectory –ExternalUrl "https://$urlpath/Oab"
Get-OwaVirtualDirectory -Identity "$CASserver\OWA (Default Web site)" | Set-OwaVirtualDirectory –ExternalUrl "https://$urlpath/Owa"
Get-ActiveSyncVirtualDirectory -Server $CASserver | Set-ActiveSyncVirtualDirectory -ExternalUrl "https://$urlpath/Microsoft-Server-ActiveSync"

}

#Get commands to doublecheck the config
[System.Console]::ForegroundColor = [System.ConsoleColor]::White

Get-AutodiscoverVirtualDirectory | ft Identity,ExternalUrl
Get-webservicesVirtualDirectory | ft Identity,ExternalUrl
Get-OabVirtualDirectory | ft Identity,ExternalUrl
Get-OwaVirtualDirectory | ft Identity,ExternalUrl
Get-ActiveSyncVirtualDirectory | ft Identity,ExternalUrl

[System.Console]::ForegroundColor = [System.ConsoleColor]::Gray

}

5{
$legacy = Read-Host "For Legacy Exchange 2003 coexistence, type external FQDN"
Write-Host "Will use" -NoNewLine
Write-Host " https://$legacy/Exchange" -NoNewLine -foregroundcolor Green
Write-Host " as Exchange 2003 URL on all Exchange 2010 Client Access Servers"

Write-Host
Write-Host "Press " -NoNewLine
Write-Host "Enter" -NoNewLine -foregroundcolor Green
Write-Host " to continue, or " -NoNewLine
Write-Host "CTR+C " -NoNewLine -foregroundcolor Red
Write-Host "to cancel"
[System.Console]::ForegroundColor = [System.ConsoleColor]::Gray
Read-Host
[System.Console]::ForegroundColor = [System.ConsoleColor]::White

Foreach($Server in Get-ClientAccessServer | Get-ExchangeServer | where-object {$_.AdminDisplayVersion.Major -eq 14}){
$CASserver = $Server.Identity

Get-OwaVirtualDirectory -Server $CASserver | Set-OwaVirtualDirectory –Exchange2003Url "https://$legacy/Exchange"

}

#get command to doublecheck the config
[System.Console]::ForegroundColor = [System.ConsoleColor]::White

Get-OwaVirtualDirectory | ft Identity,Exchange2003Url

[System.Console]::ForegroundColor = [System.ConsoleColor]::Gray

}

6{
# Display current Exchange Internal and External URL configuration
# Testing if Exchange 2010 servers present, if not dont display ECP else display with ECP

$Server = Get-ClientAccessServer | Get-ExchangeServer | where-object {$_.AdminDisplayVersion.Major -eq 14}
if ($server -eq $Null){

# No Exchange 2010 servers present

Get-AutodiscoverVirtualDirectory | fl Identity,InternalUrl,ExternalUrl
Get-ClientAccessServer | fl Identity,AutodiscoverServiceInternalUri
Get-WebservicesVirtualDirectory | fl Identity,InternalUrl,ExternalUrl
Get-OabVirtualDirectory | fl Identity,InternalUrl,ExternalUrl
Get-OwaVirtualDirectory | fl Identity,InternalUrl,ExternalUrl
Get-ActiveSyncVirtualDirectory | fl Identity,InternalUrl,ExternalUrl

[System.Console]::ForegroundColor = [System.ConsoleColor]::Gray
}
else{

# Exchange 2010 servers present

Get-AutodiscoverVirtualDirectory | fl Identity,InternalUrl,ExternalUrl
Get-ClientAccessServer | fl Identity,AutodiscoverServiceInternalUri
Get-WebservicesVirtualDirectory | fl Identity,InternalUrl,ExternalUrl
Get-OabVirtualDirectory | fl Identity,InternalUrl,ExternalUrl
Get-OwaVirtualDirectory | fl Identity,InternalUrl,ExternalUrl,Exchange2003Url
Get-EcpVirtualDirectory | fl Identity,InternalUrl,ExternalUrl
Get-ActiveSyncVirtualDirectory | fl Identity,InternalUrl,ExternalUrl

[System.Console]::ForegroundColor = [System.ConsoleColor]::Gray

}
}

7{

[System.Console]::ForegroundColor = [System.ConsoleColor]::Gray

}
        }

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: