Configure Exchange 2010 InternalUrl PowerShell script

UPDATE: This script has been updated and revamped 07.05.2010 and described in this post: http://msunified.net/2010/05/07/script-for-configuring-exchange-2010-internal-and-external-urls/

In Exchange 2010 you need to set the internal URL for various services on the Client Access Server. Outlook 2007 uses autodiscover internally to connect to the exchange server. If internal URL is configured wrong you could get certificate errors when logging on to Outlook as well as errors when using other services internally.

This script may come in handy in the following scenarios

  • Initial configuration
  • Expansion in the infrastructure with load balanced CAS
  • Change in internal FQDN if you change certificate name
  • Change from https to http
  • When you have a total disaster on site 1 and need to fail over to a second site with a passive DAG server that holds all server roles

 It is a very simple script, if you have some advice to make the script better I would be happy if you let me know. The script does the following:

  • The server path is specified with a prompt
  • The script is set up with “-identity *” if you have more than one instance you need to specify wich instance you want to configure
  • The url is generated using the variable and the default location of the services
  • After configuring the URL’s the scritp lists all changes so its easy to doublecheck the configuration
  • The UM role is excluded because it is not supported to be hosted on the same server as CAS

To run the script do the following:

  • Copy this into a txt file and rename it to a ps1 file
  • Open powershell and navigate to the location where the file is saved
  • Use tab in powershell to get the correct run syntax
  • Run it and type the correct FQDN like this when prompted: https://yourcasserver.domain.local
#InternalURL.ps1
$urlpath = Read-Host "Type internal Client Access FQDN starting with http:// or https://"
Set-AutodiscoverVirtualDirectory -Identity * –internalurl “$urlpath/autodiscover/autodiscover.xml”
Set-ClientAccessServer –Identity * –AutodiscoverServiceInternalUri “$urlpath/autodiscover/autodiscover.xml”
Set-webservicesvirtualdirectory –Identity * –internalurl “$urlpath/ews/exchange.asmx”
Set-oabvirtualdirectory –Identity * –internalurl “$urlpath/oab”
Set-owavirtualdirectory –Identity * –internalurl “$urlpath/owa”
Set-ecpvirtualdirectory –Identity * –internalurl “$urlpath/ecp”
Set-ActiveSyncVirtualDirectory -Identity * -InternalUrl "$urlpath/Microsoft-Server-ActiveSync"
#get commands to  to doublecheck the config
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

9 thoughts on “Configure Exchange 2010 InternalUrl PowerShell script

  1. Hi,
    I’ve tried to run this script, it seems to have worked correctly however my Outlook clients are still getting prompted to accept the certificate (Outlook clients are connecting to .domain.com, which isn’t on the certificate; so I want them to connect to mail.domain.com instead as this is the common name). See my post here:

    http://social.technet.microsoft.com/Forums/en/exchange2010/thread/20c35117-d7fc-4a43-81f0-4eea964febab?prof=required

    I’d appreciate any ideas you may have on this matter.

    Thanks.

  2. Edited this Script to be able to give External and Internal Adresses with orderen List Output.

    #ChangeAutodiscoverPath.ps1
    #Changing InternalURL Path
    $urlpath = Read-Host "Type Internal Client Access FQDN starting with http:// or https://"
    Set-AutodiscoverVirtualDirectory -Identity * –internalurl “$urlpath/autodiscover/autodiscover.xml”
    Set-ClientAccessServer –Identity * –AutodiscoverServiceInternalUri “$urlpath/autodiscover/autodiscover.xml”
    Set-webservicesvirtualdirectory -Identity * –internalurl “$urlpath/ews/exchange.asmx”
    Set-oabvirtualdirectory –Identity * –internalurl “$urlpath/oab”
    Set-owavirtualdirectory –Identity * –internalurl “$urlpath/owa”
    Set-ecpvirtualdirectory –Identity * –internalurl “$urlpath/ecp”
    Set-ActiveSyncVirtualDirectory -Identity * -InternalUrl "$urlpath/Microsoft-Server-ActiveSync"
    #Changing ExternalURL Path
    $urlpath2 = Read-Host "Type External Client Access FQDN starting with http:// or https://"
    Set-AutodiscoverVirtualDirectory -Identity * –externalurl “$urlpath2/autodiscover/autodiscover.xml”
    Set-ClientAccessServer –Identity * –AutodiscoverServiceInternalUri “$urlpath2/autodiscover/autodiscover.xml”
    Set-webservicesvirtualdirectory –Identity * –externalurl “$urlpath2/ews/exchange.asmx”
    Set-oabvirtualdirectory –Identity * –externalurl “$urlpath2/oab”
    Set-owavirtualdirectory –Identity * –externalurl “$urlpath2/owa”
    Set-ecpvirtualdirectory –Identity * –externalurl “$urlpath2/ecp”
    Set-ActiveSyncVirtualDirectory -Identity * -ExternalUrl "$urlpath/Microsoft-Server-ActiveSync"
    #get commands to doublecheck the config
    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-ecpvirtualdirectory | fl identity,internalurl,externalurl
    get-ActiveSyncVirtualDirectory | fl identity,internalurl,externalurl

    • Cool, thanks. I may be mistaken but seems like the url variable for ActiveSync Vdir externally is wrong, should be $urlpath2 and not $urlpath, or is it by design?

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