Skip to content

Instantly share code, notes, and snippets.

@kevinblumenfeld
Created December 15, 2020 18:38
Show Gist options
  • Save kevinblumenfeld/0e76f3d1bfdda535e9a8443622a1c62b to your computer and use it in GitHub Desktop.
Save kevinblumenfeld/0e76f3d1bfdda535e9a8443622a1c62b to your computer and use it in GitHub Desktop.
$Server = 'EXCH01'
$DC = 'APDC01'
$URI = 'https://mail.contoso.com/Autodiscover/Autodiscover.xml'
$Thumbprint = 'cccccccc'
do {
Start-Sleep -seconds 2
$scp = Get-ClientAccessServer -Identity $Server -DomainController $DC -erroraction silentlycontinue
Write-Host "Server $SERVER not found yet" -ForegroundColor Cyan
} until ($SCP) ; Set-ClientAccessServer $Server -DomainController $DC -AutoDiscoverServiceInternalUri $URI; Write-Host "Server $SERVER FOUND AND SET!!" -ForegroundColor Green
# Set-OrganizationConfig -MapiHttpEnabled $true
# Test-OutlookConnectivity -RunFromServerId $EXserver -ProbeIdentity OutlookMapiHttpSelfTestProbe
Get-OutlookAnywhere -Server $Server | Set-OutlookAnywhere -DomainController $DC -ExternalHostname mail.contoso.com -InternalHostname mail.contoso.com -ExternalClientsRequireSsl $true -InternalClientsRequireSsl $true -DefaultAuthenticationMethod NTLM -SSLOffloading $false
Get-OwaVirtualDirectory -server $Server | Set-OwaVirtualDirectory -DomainController $DC -ExternalUrl https://mail.contoso.com/owa -InternalUrl https://mail.contoso.com/owa
Get-EcpVirtualDirectory -server $Server | Set-EcpVirtualDirectory -DomainController $DC -ExternalUrl https://mail.contoso.com/ecp -InternalUrl https://mail.contoso.com/ecp
Get-ActiveSyncVirtualDirectory -server $Server | Set-ActiveSyncVirtualDirectory -DomainController $DC -ExternalUrl https://mail.contoso.com/Microsoft-Server-ActiveSync -InternalUrl https://mail.contoso.com/Microsoft-Server-ActiveSync
Get-WebServicesVirtualDirectory -server $Server | Set-WebServicesVirtualDirectory -ExternalUrl 'https://hybrid.contoso.net/EWS/Exchange.asmx' -InternalUrl 'https://hybrid.contoso.net/EWS/Exchange.asmx' -BasicAuthentication $true
# If needing to migrate cross forest or if this is a hybrid server: Set-WebServicesVirtualDirectory -BasicAuthentication $true
Get-OabVirtualDirectory -server $Server | Set-OabVirtualDirectory -DomainController $DC -ExternalUrl https://mail.contoso.com/OAB -InternalUrl https://mail.contoso.com/OAB
Get-ClientAccessServer -Identity $Server | Set-ClientAccessServer -DomainController $DC -AutoDiscoverServiceInternalUri https://mail.contoso.com/Autodiscover/Autodiscover.xml
Get-MapiVirtualDirectory -server $Server | Set-MapiVirtualDirectory -DomainController $DC -ExternalUrl https://mail.contoso.com/MAPI -InternalUrl https://mail.contoso.com/MAPI
# Import-ExchangeCertificate -FileData ([Byte[]]$(Get-Content -Path "C:\scripts\contosoCertExchange.pfx" -Encoding byte -ReadCount 0)) -Password:(Get-Credential).password
Enable-ExchangeCertificate -Thumbprint $Thumbprint -Server $Server -Services POP, IMAP, SMTP, IIS -DomainController $DC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment