How to set all virtual directories at once With PowerShell

For internal URLs:

$urlpath = Read-Host "Type internal Client Access FQDN starting with http:// or https://"

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"

External URLs:

Set-ClientAccessServer –Identity * –AutodiscoverServiceExternalUri “$urlpath/autodiscover/autodiscover.xml”
Set-webservicesvirtualdirectory –Identity * -ExternalUrl “$urlpath/ews/exchange.asmx”
Set-oabvirtualdirectory –Identity * –ExternalUrl “$urlpath/oab”
Set-owavirtualdirectory –Identity * –ExternalUrl “$urlpath/owa”
Set-ecpvirtualdirectory –Identity * –ExternalUrl “$urlpath/ecp”
Set-ActiveSyncVirtualDirectory -Identity * -ExternalUrl "$urlpath/Microsoft-Server-ActiveSync

save it as a .ps1 extension and run it in Exchange Management Shell

This entry was posted in Exchange 2010, Exchange 2013, Microsoft Exchange, PowerShell and tagged , , , . Bookmark the permalink.

Leave a Reply