{"id":505,"date":"2019-06-25T10:45:01","date_gmt":"2019-06-25T15:45:01","guid":{"rendered":"http:\/\/itblog.ldlnet.net\/?p=505"},"modified":"2019-06-25T10:45:01","modified_gmt":"2019-06-25T15:45:01","slug":"exchange-server-client-access-url-configuration-script","status":"publish","type":"post","link":"https:\/\/itblog.ldlnet.net\/index.php\/2019\/06\/25\/exchange-server-client-access-url-configuration-script\/","title":{"rendered":"Exchange Server Client Access URL Configuration Script"},"content":{"rendered":"\n<p>In my career, I have to be able to be efficient as most of my projects are on a time crunch schedule. Being able to quickly configure Exchange when setting up a server environment is crucial to the success of the project.<\/p>\n\n\n\n<p>While still honing my skills in PowerShell, I was attempting to create my own script to help configure all of the Virtual Directories in one shot rather than go to each setting and configure them manually. It did not go very well, so as I do, I research and find great professionals that do great work in scripting so that I may learn from them.<\/p>\n\n\n\n<p>In doing so, I found <a aria-label=\"Paul Cunningham's script (opens in a new tab)\" rel=\"noreferrer noopener\" href=\"https:\/\/gallery.technet.microsoft.com\/office\/Exchange-Server-Client-510ad60b\" target=\"_blank\"><strong>Paul Cunningham&#8217;s script<\/strong><\/a> that performs this. I took the following script and modified it to add the PowerShell Virtual Directory to it as I like to configure that as well. <\/p>\n\n\n\n<p class=\"has-text-color has-small-font-size has-medium-pink-color\"><strong>***YOU CAN REM THE LINES OUT SHOULD YOU NOT WANT TO CONFIGURE THAT DIRECTORY***<\/strong><\/p>\n\n\n\n<p>Here is my version of the script:<\/p>\n\n\n<pre class=\"lang:PowerShell nums:True\" title=\"ConfigureExchangeURLs.ps1\"><#\n.SYNOPSIS\nConfigureExchangeURLs.ps1\n\n.DESCRIPTION \nPowerShell script to configure the Client Access server URLs\nfor Microsoft Exchange Server 2013\/2016. All Client Access server\nURLs will be set to the same namespace.\n\nIf you are using separate namespaces for each CAS service this script will\nnot handle that.\n\nThe script sets Outlook Anywhere to use NTLM with SSL required by default.\nIf you have different auth requirements for Outlook Anywhere  use the optional\nparameters to set those.\n\n.PARAMETER Server\nThe name(s) of the server(s) you are configuring.\n\n.PARAMETER InternalURL\nThe internal namespace you are using.\n\n.PARAMETER ExternalURL\nThe external namespace you are using.\n\n.PARAMETER InternalSSL\nSpecifies the internal SSL requirement for Outlook Anywhere. Defaults to True (SSL required).\n\n.PARAMETER ExternalSSL\nSpecifies the external SSL requirement for Outlook Anywhere. Defaults to True (SSL required).\n\n.EXAMPLE\n.\\ConfigureExchangeURLs.ps1 -Server sydex1 -InternalURL mail.exchangeserverpro.net -ExternalURL mail.exchangeserverpro.net\n\n.EXAMPLE\n.\\ConfigureExchangeURLs.ps1 -Server sydex1,sydex2 -InternalURL mail.exchangeserverpro.net -ExternalURL mail.exchangeserverpro.net\n\n.LINK\nhttp:\/\/exchangeserverpro.com\/powershell-script-configure-exchange-urls\/\n\n.NOTES\nWritten by: Paul Cunningham\n\nFor more Exchange Server tips, tricks and news\ncheck out Exchange Server Pro.\n\n* Website:\thttp:\/\/exchangeserverpro.com\n* Twitter:\thttp:\/\/twitter.com\/exchservpro\n\nFind me on:\n\n* My Blog:\thttp:\/\/paulcunningham.me\n* Twitter:\thttps:\/\/twitter.com\/paulcunningham\n* LinkedIn:\thttp:\/\/au.linkedin.com\/in\/cunninghamp\/\n* Github:\thttps:\/\/github.com\/cunninghamp\n\nLicense:\n\nThe MIT License (MIT)\n\nCopyright (c) 2015 Paul Cunningham\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and\/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\nChange Log:\nV1.00, 13\/11\/2014 - Initial version\nV1.01, 26\/06\/2015 - Added MAPI\/HTTP URL configuration\nV1.02, 27\/08\/2015 - Improved error handling, can now specify multiple servers to configure at once.\nV1.03, 09\/09\/2015 - ExternalURL can now be $null\nV1.04, 17\/11\/2016 - Removed Outlook Anywhere auth settings, script now sets URLs only\nV1.05, 18\/11\/2016 - Added AutodiscoverSCP option so it can be set to a different URL than other services\nV1.06, 25\/06\/2019 - Added PowerShell Virtual Directory Configuration Requiring SSL and using Basic Authentication\n\n.ADDENDUM\nV1.06 Modified by Lance Lingerfelt for similar use. \n\n* Website:\thttp:\/\/www.ldlnet.net\n* IT Blog:\t       http:\/\/itblog.ldlnet.net\n\n#>\n\n#requires -version 2\n\n[CmdletBinding()]\nparam(\n\t[Parameter( Position=0,Mandatory=$true)]\n\t[string[]]$Server,\n\n\t[Parameter( Mandatory=$true)]\n\t[string]$InternalURL,\n\n\t[Parameter( Mandatory=$true)]\n    [AllowEmptyString()]\n\t[string]$ExternalURL,\n\n\t[Parameter( Mandatory=$false)]\n\t[string]$AutodiscoverSCP,\n\n    [Parameter( Mandatory=$false)]\n    [Boolean]$InternalSSL=$true,\n\n    [Parameter( Mandatory=$false)]\n    [Boolean]$ExternalSSL=$true\n\t)\n\n\n#...................................\n# Script\n#...................................\n\nBegin {\n\n    #Add Exchange snapin if not already loaded in the PowerShell session\n    if (Test-Path $env:ExchangeInstallPath\\bin\\RemoteExchange.ps1)\n    {\n\t    . $env:ExchangeInstallPath\\bin\\RemoteExchange.ps1\n\t    Connect-ExchangeServer -auto -AllowClobber\n    }\n    else\n    {\n        Write-Warning \"Exchange Server management tools are not installed on this computer.\"\n        EXIT\n    }\n}\n\nProcess {\n\n    foreach ($i in $server)\n    {\n        if ((Get-ExchangeServer $i -ErrorAction SilentlyContinue).IsClientAccessServer)\n        {\n            Write-Host \"----------------------------------------\"\n            Write-Host \" Configuring $i\"\n            Write-Host \"----------------------------------------`r`n\"\n            Write-Host \"Values:\"\n            Write-Host \" - Internal URL: $InternalURL\"\n            Write-Host \" - External URL: $ExternalURL\"\n            Write-Host \" - Outlook Anywhere internal SSL required: $InternalSSL\"\n            Write-Host \" - Outlook Anywhere external SSL required: $ExternalSSL\"\n            Write-Host \"`r`n\"\n\n            Write-Host \"Configuring Outlook Anywhere URLs\"\n            $OutlookAnywhere = Get-OutlookAnywhere -Server $i\n            $OutlookAnywhere | Set-OutlookAnywhere -ExternalHostname $externalurl -InternalHostname $internalurl `\n                                -ExternalClientsRequireSsl $ExternalSSL -InternalClientsRequireSsl $InternalSSL `\n                                -ExternalClientAuthenticationMethod $OutlookAnywhere.ExternalClientAuthenticationMethod\n\n            if ($externalurl -eq \"\")\n            {\n                Write-Host \"Configuring Outlook Web App URLs\"\n                Get-OwaVirtualDirectory -Server $i | Set-OwaVirtualDirectory -ExternalUrl $null -InternalUrl https:\/\/$internalurl\/owa\n\n                Write-Host \"Configuring Exchange Control Panel URLs\"\n                Get-EcpVirtualDirectory -Server $i | Set-EcpVirtualDirectory -ExternalUrl $null -InternalUrl https:\/\/$internalurl\/ecp\n\n                Write-Host \"Configuring ActiveSync URLs\"\n                Get-ActiveSyncVirtualDirectory -Server $i | Set-ActiveSyncVirtualDirectory -ExternalUrl $null -InternalUrl https:\/\/$internalurl\/Microsoft-Server-ActiveSync\n\n                Write-Host \"Configuring Exchange Web Services URLs\"\n                Get-WebServicesVirtualDirectory -Server $i | Set-WebServicesVirtualDirectory -ExternalUrl $null -InternalUrl https:\/\/$internalurl\/EWS\/Exchange.asmx\n\n                Write-Host \"Configuring Offline Address Book URLs\"\n                Get-OabVirtualDirectory -Server $i | Set-OabVirtualDirectory -ExternalUrl $null -InternalUrl https:\/\/$internalurl\/OAB\n\n                Write-Host \"Configuring MAPI\/HTTP URLs\"\n                Get-MapiVirtualDirectory -Server $i | Set-MapiVirtualDirectory -ExternalUrl $null -InternalUrl https:\/\/$internalurl\/mapi\n\n                Write-Host \"Configuring PowerShell URLs\"\n                Get-PowerShellVirtualDirectory -Server $i | Set-PowerShellVirtualDirectory -ExternalUrl $null -InternalUrl https:\/\/$internalurl\/PowerShell -BasicAuthentication $True -RequireSSL $True -Confirm:$False\n            }\n            else\n            {\n                Write-Host \"Configuring Outlook Web App URLs\"\n                Get-OwaVirtualDirectory -Server $i | Set-OwaVirtualDirectory -ExternalUrl https:\/\/$externalurl\/owa -InternalUrl https:\/\/$internalurl\/owa\n\n                Write-Host \"Configuring Exchange Control Panel URLs\"\n                Get-EcpVirtualDirectory -Server $i | Set-EcpVirtualDirectory -ExternalUrl https:\/\/$externalurl\/ecp -InternalUrl https:\/\/$internalurl\/ecp\n\n                Write-Host \"Configuring ActiveSync URLs\"\n                Get-ActiveSyncVirtualDirectory -Server $i | Set-ActiveSyncVirtualDirectory -ExternalUrl https:\/\/$externalurl\/Microsoft-Server-ActiveSync -InternalUrl https:\/\/$internalurl\/Microsoft-Server-ActiveSync\n\n                Write-Host \"Configuring Exchange Web Services URLs\"\n                Get-WebServicesVirtualDirectory -Server $i | Set-WebServicesVirtualDirectory -ExternalUrl https:\/\/$externalurl\/EWS\/Exchange.asmx -InternalUrl https:\/\/$internalurl\/EWS\/Exchange.asmx\n\n                Write-Host \"Configuring Offline Address Book URLs\"\n                Get-OabVirtualDirectory -Server $i | Set-OabVirtualDirectory -ExternalUrl https:\/\/$externalurl\/OAB -InternalUrl https:\/\/$internalurl\/OAB\n\n                Write-Host \"Configuring MAPI\/HTTP URLs\"\n                Get-MapiVirtualDirectory -Server $i | Set-MapiVirtualDirectory -ExternalUrl https:\/\/$externalurl\/mapi -InternalUrl https:\/\/$internalurl\/mapi\n\n                Write-Host \"Configuring PowerShell URLs\"\n                Get-PowerShellVirtualDirectory -Server $i | Set-PowerShellVirtualDirectory -ExternalUrl https:\/\/$externalurl\/PowerShell -InternalUrl https:\/\/$internalurl\/PowerShell -BasicAuthentication $True -RequireSSL $True -Confirm:$False\n            }\n\n            Write-Host \"Configuring Autodiscover\"\n            if ($AutodiscoverSCP) {\n                Get-ClientAccessServer $i | Set-ClientAccessServer -AutoDiscoverServiceInternalUri https:\/\/$AutodiscoverSCP\/Autodiscover\/Autodiscover.xml\n            }\n            else {\n                Get-ClientAccessServer $i | Set-ClientAccessServer -AutoDiscoverServiceInternalUri https:\/\/$internalurl\/Autodiscover\/Autodiscover.xml\n            }\n\n\n            Write-Host \"`r`n\"\n        }\n        else\n        {\n            Write-Host -ForegroundColor Yellow \"$i is not a Client Access server.\"\n        }\n    }\n}\n\nEnd {\n\n    Write-Host \"Finished processing all servers specified. Consider running Get-CASHealthCheck.ps1 to test your Client Access namespace and SSL configuration.\" -ForegroundColor Yellow\n    Write-Host \"Refer to http:\/\/exchangeserverpro.com\/testing-exchange-server-2013-client-access-server-health-with-powershell\/ for more details.\"\n    Write-Host \"Also check out http:\/\/itblog.ldlnet.net for Lance's IT Blog of information!\" -ForegroundColor Gray\n\n}\n\n#...................................\n# Finished\n#...................................\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">NOTES:<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li>PowerShell script to configure the Client Access server URLs for Microsoft Exchange Server 2013\/2016. All Client Access server URLs will be set to the same namespace.<\/li><li>If you are using separate namespaces for each CAS service this script will not handle that.<\/li><li>The script sets Outlook Anywhere to use NTLM with SSL required by default.<\/li><li> If you have different auth requirements for Outlook Anywhere use the optional parameters to set those.<\/li><li>The script sets PowerShell to use Basic with SSL required by default.<\/li><li> If you have different authentication requirements for PowerShell use the optional parameters to set those.<\/li><li>PowerShell was added to the settings. Please be sure to REM those lines of code should you NOT want to configure the PowerShell Virtual Directory.<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">USAGE:<\/h3>\n\n\n<pre class=\"lang:PowerShell nums:False\" title=\"ConfigureExchangeURLs.ps1 usage single server\">.\\ConfigureExchangeURLs.ps1 -Server EX01 -InternalURL mail.ldlnet.net -ExternalURL mail.ldlnet.net<\/pre>\n<pre class=\"lang:PowerShell nums:False\" title=\"ConfigureExchangeURLs.ps1 usage multiple servers\">.\\ConfigureExchangeURLs.ps1 -Server EX01,EX02,EX03 -InternalURL mail.ldlnet.net -ExternalURL mail.ldlnet.net<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" style=\"text-align:center\">HAPPY SCRIPTING!<br>POSITIVE ENERGY!<br>PLEASE COMMENT!<\/h2>\n\n\n\n<p class=\"has-small-font-size\"><strong><em>REFERENCES:<\/em><\/strong><br><a aria-label=\"Exchange Server Client Access URL Configuration Script (opens in a new tab)\" rel=\"noreferrer noopener\" href=\"https:\/\/gallery.technet.microsoft.com\/office\/Exchange-Server-Client-510ad60b\" target=\"_blank\">Exchange Server Client Access URL Configuration Script<\/a><br><a href=\"https:\/\/practical365.com\/exchange-server\/powershell-script-configure-exchange-urls\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"PowerShell Script to Configure Exchange Server Client Access URLs (opens in a new tab)\">PowerShell Script to Configure Exchange Server Client Access URLs<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my career, I have to be able to be efficient as most of my projects are on a time crunch schedule.<\/p>\n<p class=\"link-more\"><a class=\"myButt \" href=\"https:\/\/itblog.ldlnet.net\/index.php\/2019\/06\/25\/exchange-server-client-access-url-configuration-script\/\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":161,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,2,194,3],"tags":[9,150,149,151,147,8,13],"class_list":["post-505","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-exchange","category-general","category-office365","category-powershell","tag-exchange","tag-exchange-2013","tag-exchange-2016","tag-exchange-2019","tag-exchange-setup","tag-powershell","tag-script","odd"],"_links":{"self":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts\/505","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/comments?post=505"}],"version-history":[{"count":4,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts\/505\/revisions"}],"predecessor-version":[{"id":170449,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts\/505\/revisions\/170449"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/media\/161"}],"wp:attachment":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/media?parent=505"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/categories?post=505"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/tags?post=505"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}