Initial Configuration of Exchange 2010 with PowerShell

Please refer to the following PowerShell Script on how to configure some basic settings for Fresh installed Exchange 2010 Server (Single Server enviroment)

Rename the Mailbox Database

Get-MailboxDatabase | Set-Mailbox -Name LOCAL #Rename Mailbox Database

Add Accepted Domain and set it as default

New-AcceptedDomain -DomainName AventisLab.com -DomainType Authoritative -Name AventisLab.com
Set-AcceptedDomain -Identity AventisLab.com -MakeDefault $true

Configure the Default Email Address Policy to include the newly added accpeted domain as default

Get-EmailAddressPolicy | Set-EmailAddressPolicy -EnabledPrimarySMTPAddressTemplate "@AventisLab.com"
Get-EmailAddressPolicy | Update-EmailAddressPolicy 

Configure SMTP Connector
Please sign up a free SMTP Account from SMTP2GO as smart host as the public IP Address in mylab are always blacklisted

Login to SMTP2GO, and allow our Public IP Address for SMTP Relay

$UserName = "kwyong@aventistech.com"
$Password = "5gpclhrSLvBF" | ConvertTo-SecureString -AsPlainText -Force 
$Credential = new-object -typename System.Management.Automation.PSCredential -ArgumentList $UserName,$Password
New-SendConnector -Internet -Name "SMTP Connector" -AddressSpaces * -SmartHosts mail.smtp2go.com -SmartHostAuthMechanism BasicAuth `
-AuthenticationCredential $Credential -Enabled $true

Enabled AnonymousUsers Permission for Default Receiver Connector – To be able to received Email

Get-ReceiveConnector | ? Bindings -like "*25*" | Set-ReceiveConnector -PermissionGroups AnonymousUsers,ExchangeUsers,ExchangeServers

Configure OWA, ECP, OAB, ActiveSync & EWS URL – For External Only

$OWA_URL="https://mail.aventislab.com/owa"
$ECP_URL="https://mail.aventislab.com/ecp"
$ActiveSync_URL="https://mail.aventislab.com/Microsoft-Server-ActiveSync"
$OAB_URL="https://mail.aventislab.com/OAB"
$EWS_URL="https://mail.aventislab.com/ews/exchange.asmx"
Get-OwaVirtualDirectory | Set-OwaVirtualDirectory -ExternalUrl $OWA_URL -DefaultDomain mylab -LogonFormat UserName 
Get-EcpVirtualDirectory | Set-EcpVirtualDirectory -ExternalUrl $ECP_URL
Get-ActiveSyncVirtualDirectory | Set-ActiveSyncVirtualDirectory -ExternalUrl $ActiveSync_URL
Get-OabVirtualDirectory | Set-OabVirtualDirectory -ExternalUrl $OAB_URL
Get-WebServicesVirtualDirectory | Set-WebServicesVirtualDirectory -ExternalUrl $EWS_URL

Enable Outlook Anywhere

Enable-OutlookAnywhere -Server AVT-EX10 -ExternalHostname mail.aventislab.com -ClientAuthenticationMethod basic -SSLOffloading:$true

Obtain the Wildcard SSL Certificate from Let’s Encrypt and import the SSL Certificate to Exchange 2010

Get-ExchangeCertificate | ? Subject -like "**.aventislab.com*" | Enable-ExchangeCertificate -Services IIS

Leave a Comment