Changing multiple Exchange Virtual Directories across a CAS Array quickly and accurately

by Steve Goodman [Published on 7 Nov. 2012 / Last Updated on 3 Oct. 2012]

Ever need to configure multiple Virtual Directories across all Exchange Client Access Servers within a Client Access Array? This script will show you how to save some time..

If you’ve got the need to change the Internal and External URLs for multiple Exchange Virtual Directories across all members of a Client Access Array, then it can be time consuming and error prone.

You can simplify this by using a couple of PowerShell cmdlets to obtain a list of all the members of the Client Access Array, and then change the Internal and External URLs in one operation.

As a simple example, let’s have a look at look at how we can use this technique to change the Outlook Web App virtual directory Internal and External URLs for all members of the Client Access Array:

$ClientAccessArray = ""              $OWAVDirs = (Get-ClientAccessArray $ClientAccessArray).Members | Get-ExchangeServer | Get-OWAVirtualDirectory              $OWAVDirs | Set-OWAVirtualDirectory -InternalURL "" -ExternalURL ""              

As you can see, it’s pretty straightforward. We’ve retrieved a list of members of the client access array (basically all Client Access Servers in the site that houses the CAS array), and retrieved information that we can pass to Set-OWAVirtualDirectory using Get-ExchangeServer.

But how about if we wanted to change all Virtual Directories, and the AutoDiscover Service Connection Point (SCP) in one operation to all use the same Fully Qualified Domain Name (FQDN)? We can do that too, again reasonably easily:

$ClientAccessArray = ""              $Int_HTTPS_FQDN = ""              $Ext_HTTPS_FQDN = ""              $AutoD_FQDN = ""              $CASServers = (Get-ClientAccessArray $ClientAccessArray).Members | Get-ExchangeServer               $CASServers | Get-OWAVirtualDirectory | Set-OWAVirtualDirectory -InternalURL "https://$($Int_HTTPS_FQDN)/owa" -ExternalURL "https://$($Ext_HTTPS_FQDN)/owa"              $CASServers | Get-ECPVirtualDirectory | Set-ECPVirtualDirectory -InternalURL "https://$($Int_HTTPS_FQDN)/ecp" -ExternalURL "https://$($Ext_HTTPS_FQDN)/ecp"              $CASServers | Get-OABVirtualDirectory | Set-OABVirtualDirectory -InternalURL "https://$($Int_HTTPS_FQDN)/oab" -ExternalURL "https://$($Ext_HTTPS_FQDN)/oab"              $CASServers | Get-ActiveSyncVirtualDirectory | Set-ActiveSyncVirtualDirectory -InternalURL "https://$($Int_HTTPS_FQDN)/Microsoft-Server-ActiveSync" -ExternalURL "https://$($Ext_HTTPS_FQDN)/Microsoft-Server-ActiveSync"              $CASServers | Get-WebServicesVirtualDirectory | Set-WebServicesVirtualDirectory -InternalURL "https://$($Int_HTTPS_FQDN)/EWS/Exchange.asmx" -ExternalURL "https://$($Ext_HTTPS_FQDN)/EWS/Exchange.asmx"              $CASServers | Get-ClientAccessServer | Set-ClientAccessServer -AutoDiscoverServiceInternalURI "https://$($AutoD_FQDN)/AutoDiscover/AutoDiscover.xml"              

Just remember, if you’re using these commands in your production environment, always use the –WhatIf parameter against the Set-* cmdlets to double check the operation is performing the action you expect.

See Also

See Also

Featured Links