Saturday, May 29, 2010

the Exchange 2010 Configurator Script

Hi There,


I often win points on EE by answering lots of web services question, and also spending lots of troubleshooting EWS on EE, of course I win points, but after all users experience have been degraded and admins suffered.



If you read my previous article http://www.experts-exchange.com/articles/Software/Server_Software/Email_Servers/Exchange/Exchange-2007-2010-Web-services-and-Autodiscover-Ultimate-Troubleshooting-Guide.html you will find that there are lot of configuration that must be done on the Exchange web services including (OWA, ECP,EWS,EAS,OAB) for outlook and Exchange to work smoothly.



I always find lot of people running into troubles configuring their Exchange server and using the poweshell, so I created this nice powershell script that will answer you very simple questions and configure Exchange web services including (OWA, ECP, OAB, AES, Internal SCP, EWS)
Here is the script notes:



Internal domain name entered in the FQDN format.





Server name entered in netbios format.





Autodiscover and webmail URLs are entered in FQDN format with no HTTP or HTTPS.





Internal name are set to server FQDN thus the certificate has to include the server name as well.





If you have multiple servers you will need to run the script for each server.



Other than this attached the script file along with the script itself here for your reference, you can use and customize this script to meet your need, use the script at your own responsibility blab la bla (legal stuff ), and your comment and feedback are welcome on e14(at)Ingazat(dot)com.
##################################################################################
#Add exchange 2010 snap in for mailbox creation


Add-PSSnapin Microsoft.Exchange.Management.Powershell.E2010 -ea silentlyContinue


write-Host "Welcome to the Exchange configurator, This script will help you to configure the Exchange web services to avoid common missing


and wrong configuration, This script is created by Mahmoud Magdy (http://busbar.blogspot.com)m


you can reach me by email on e14(at)ingazat(dot)com use this script under your own responsibility"


write-Host "The Configurator will list the current system configuration for your reference the config will be saved to c:\e14systemconfig.txt"


$systemconfig = @(Get-OwaVirtualDirectory
fl name,internalurl,externalurl)


$systemconfig = $systemconfig + @(Get-ecpVirtualDirectory
fl name,internalurl,externalurl)


$systemconfig = $systemconfig + @(Get-oabVirtualDirectory
fl name,internalurl,externalurl)


$systemconfig = $systemconfig + @(Get-WebServicesVirtualDirectory
fl name,internalurl,externalurl)


$systemconfig = $systemconfig + @(Get-ActiveSyncVirtualDirectory
fl name,internalurl,externalurl)


$systemconfig = $systemconfig + @(Get-ClientAccessServer
fl Name,AutoDiscoverServiceInternalUri)


$systemconfig
out-file c:\e14systemconfig.txt






write-Host "The Configurator will start asking you some questions then will configure your environment"






$InternalDomainname = Read-Host "What is the name of the Internal domain name"


$Servername = Read-Host "What is the name of the Internal server name"


$Externalwebmail = Read-Host "what is the url used by users to acces OWA Externally e.g mail.domain.com


please don't include https://"


$InternalAutodiscover = Read-Host "what is the url used by users to acces autodiscover internal URL


(this will be retrieved from AD SCP please don't include https://"


$InternalURL = $servername + "." + $internaldomainname


$ServernameURL = "https://" + $InternalURL


$httpsExternalwebmail = "https://" + $Externalwebmail


$owaextURL = $httpsExternalwebmail + "/owa"


$owaintURL = $ServernameURL + "/owa"






$ecpextURL = $httpsExternalwebmail + "/ecp"


$ecpintURL = $ServernameURL + "/ecp"






$EWSexternalURL = $httpsExternalwebmail + "/EWS/Exchange.asmx"


$EWSInternalURL = $ServernameURL + "/EWS/Exchange.asmx"






$oabextURL = $httpsExternalwebmail + "/oab"


$oabintURL = $ServernameURL + "/oab"






$EASexturl = $httpsExternalwebmail + "/Microsoft-Server-ActiveSync"


$EASinturl = $ServernameURL + "/Microsoft-Server-ActiveSync"






$Autodiscogerinternalurl = $InternalAutodiscover + "/Autodiscover/Autodiscover.xml"






$Autodiscogerinternalurl = "https://" + $Autodiscogerinternalurl


write-Host "The Configurator will start Configuring your System now"


get-owavirtualdirectory -server $servername
set-owavirtualdirectory -ExternalUrl $owawextURL -InternalUrl $owawintURL


get-ecpVirtualDirectory -server $servername
set-ecpVirtualDirectory -ExternalUrl $ecpextURL -InternalUrl $ecpintURL


get-oabVirtualDirectory -server $servername
set-oabVirtualDirectory -ExternalUrl $oabextURL -InternalUrl $oabintURL


get-WebServicesVirtualDirectory -server $servername
set-WebServicesVirtualDirectory -ExternalUrl $EWSexternalURL -InternalUrl $EWSInternalURL


get-ActiveSyncVirtualDirectory -server $servername
set-ActiveSyncVirtualDirectory -ExternalUrl $EASexturl -InternalUrl $EASinturl


Get-ClientAccessServer -Identity $Servername
Set-ClientAccessServer -AutoDiscoverServiceInternalUri $Autodiscogerinternalurl






write-Host "The Configurator is done you might want to run this script on other servers"
#########################################################################




save the code above to scriptname.ps1 and run it by double click on it, you can run this PS from windows powershell (I added the Exchange snapin) or the Exchange management shell.



I hope to win less points on EE from EWS and win more points from this article

No comments: