Site icon Franky's Web

Exchange 2019: Determine host names for the certificate

Once an Exchange 2019 server has been configured, an SSL certificate needs to be installed. For the correct configuration of the certificate, the hostnames that are relevant for the certificate must be determined. The following script reads the hostnames from the configured URLs of the virtual directories and displays the corresponding hostnames in the Exchange Management Shell. The script does not perform any configuration and is only used to check the configuration and to help with the configuration of the certificate:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#Getting Exchange FQDNs from configured URLs
#Local Server Name
try {
 $ExchangeServer = (Get-ExchangeServer $env:computername).name
}
catch {
}
#Autodiscover
try {
 $AutodiscoverFQDN = ((Get-ClientAccessService -Identity $ExchangeServer).AutoDiscoverServiceInternalUri.Host).ToLower()
 [array]$CertNames += $AutodiscoverFQDN
}
catch {
}
#Outlook Anywhere
try {
 $OAExtFQDN = ((Get-OutlookAnywhere -server $ExchangeServer).ExternalHostname.Hostnamestring).ToLower()
 [array]$CertNames += $OAExtFQDN
 $OAIntFQDN = ((Get-OutlookAnywhere -server $ExchangeServer).Internalhostname.Hostnamestring).ToLower()
 [array]$CertNames += $OAIntFQDN
}
catch {
}
#OAB
try {
 $OABExtFQDN = ((Get-OabVirtualDirectory -server $ExchangeServer).ExternalUrl.Host).ToLower()
 [array]$CertNames += $OABExtFQDN
 $OABIntFQDN = ((Get-OabVirtualDirectory -server $ExchangeServer).Internalurl.Host).ToLower()
 [array]$CertNames += $OABIntFQDN
}
catch {
}
#ActiveSync
try {
 $EASIntFQDN = ((Get-ActiveSyncVirtualDirectory -server $ExchangeServer).Internalurl.Host).ToLower()
 [array]$CertNames += $EASIntFQDN
 $EASExtFQDN = ((Get-ActiveSyncVirtualDirectory -server $ExchangeServer).ExternalUrl.Host).ToLower()
 [array]$CertNames += $EASExtFQDN
}
catch {
}
#EWS
try {
 $EWSIntFQDN = ((Get-WebServicesVirtualDirectory -server $ExchangeServer).Internalurl.Host).ToLower()
 [array]$CertNames += $EWSIntFQDN
 $EWSExtFQDN = ((Get-WebServicesVirtualDirectory -server $ExchangeServer).ExternalUrl.Host).ToLower()
 [array]$CertNames += $EWSExtFQDN
}
catch {
}
#ECP
try {
 $ECPIntFQDN = ((Get-EcpVirtualDirectory -server $ExchangeServer).Internalurl.Host).ToLower()
 [array]$CertNames += $ECPIntFQDN
 $ECPExtFQDN = ((Get-EcpVirtualDirectory -server $ExchangeServer).ExternalUrl.Host).ToLower()
 [array]$CertNames += $ECPExtFQDN
}
catch {
}
#OWA
try {
 $OWAIntFQDN =  ((Get-OwaVirtualDirectory -server $ExchangeServer).Internalurl.Host).ToLower()
 [array]$CertNames += $OWAIntFQDN
 $OWAExtFQDN = ((Get-OwaVirtualDirectory -server $ExchangeServer).ExternalUrl.Host).ToLower()
 [array]$CertNames += $OWAExtFQDN
}
catch {
}
#MAPI
try {
 $MAPIIntFQDN = ((Get-MapiVirtualDirectory -server $ExchangeServer).Internalurl.Host).ToLower()
 [array]$CertNames += $MAPIIntFQDN
 $MAPIExtFQDN = ((Get-MapiVirtualDirectory -server $ExchangeServer).ExternalUrl.Host).ToLower()
 [array]$CertNames += $MAPIExtFQDN
}
catch {
}
#Make FQDNs unique
try {
 $CertNames = $CertNames | select -Unique
}
catch {
}
write-host "
Autodiscover Hostname: $AutodiscoverFQDN
Outlook Anywhere Hostname (Internal): $OAIntFQDN
Outlook Anywhere Hostname (External): $OAExtFQDN
ActiveSync Hostname (Internal): $EASIntFQDN
ActiveSync Hostname (External): $EASExtFQDN
OAB Hostname (Internal): $OABIntFQDN
OAB Hostname (External): $OABExtFQDN
EWS Hostname (Internal): $EWSIntFQDN
EWS Hostname (External): $EWSExtFQDN
ECP Hostname (Internal): $ECPIntFQDN
ECP Hostname (External): $ECPExtFQDN
OWA Hostname (Internal): $OWAIntFQDN
OWA Hostname (External): $OWAExtFQDN
MAPI Hostname (Internal): $MAPIIntFQDN
MAPI Hostname (External): $MAPIExtFQDN
"
write-host "
SANs needed for Certificate:
"
$CertNames
write-host "
Use this Hostname as Common Name (CN): $OWAExtFQDN
"

The output of the script on the Exchange Management Shell then looks as follows:

The script provides the host names which must be present on the certificate as SAN (Subject Alternate Name) and CN (Common Name).

The script is also available for download here:

Here you can find an article on the basic configuration for Exchange 2019:

A detailed white paper on Exchange Server and certificates is currently in progress. This script is just a small excerpt from the new whitepaper.

Exit mobile version