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

About Idit Bnaya

Sr. Cloud Solution Architect at Microsoft, I’m passionate about helping customers succeed by building secure, scalable, and innovative cloud solutions – with a strong focus on AI, DevOps practices, and end-to-end security. With a proven track record in the IT and services industry, I serve as a trusted advisor, partnering closely with organizations to guide them through digital transformation and maximize the value of their cloud investments. My role combines technical leadership with project ownership – from designing modern architectures to leading cross-functional implementations that drive real business outcomes. I also manage and empower strategic partners, working hand-in-hand with them to ensure project success and deliver measurable business impact for customers.
This entry was posted in Exchange 2010, Exchange 2013, Microsoft Exchange, PowerShell and tagged , , , . Bookmark the permalink.

Leave a Reply