-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget-virdirinfo.ps1
580 lines (519 loc) · 24.3 KB
/
get-virdirinfo.ps1
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
#========================================================================================================
# Created on: 12/16/2012 09:30 PM
# Last Update: 12/09/2016 4:05 PM
# Created by: Michael Van Horenbeeck
# Website: http://www.vanhybrid.com
# Filename: get-virdirinfo.ps1
# Version: 1.8
# Credits: Thomas Torggler for some great ideas and remarks (@Torggler)
# http://social.technet.microsoft.com/wiki/contents/articles/240.exchange-server-and-update-rollups-build-numbers.aspx
#
# Version History: 1.8 Updated script issues after Exchange 2016 CU2 update. Script can now be executed on 2016 CU2+ servers.
# Included more Exchange Version numbers. Added a few strings and switched to using Get-ClientAccessServices for 2016 CU2+ servers.
# 1.7 Updated build numbers to include more recent versions
# 1.6 Will only discover MAPI virtual directory if servers are Exchange 2013 SP1+
# Added OWA and ECP authentication information, Autodiscover Site Scope, General Server info
# Script now also translates build number into version name
# 1.5 Added check for the new MAPI virtual directory, added in Exchange 2013 SP1 (CU4),
# re-added WebServices Virtual Directory to script.
# 1.4 Added "Last modified on"
# 1.3 Added -Filter parameter, improved error handling in general, added warnings
#
# 1.2 Added -ADPropertiesOnly parameter to speed up the script
# 1.1 Fixed count error when only a single server exists
# 1.0 Initial Version
#========================================================================================================
<#
.Synopsis
This script will create an HTML-report which will gather the URL-information from different virtual directories over different Exchange Servers (currently only Exchange 2010/Exchange 2013)
.DESCRIPTION
This script will create an HTML-report which will gather the URL-information from different virtual directories over different Exchange Servers (currently only Exchange 2010/Exchange 2013)
.EXAMPLE
. .\get-virdirinfo.ps1
Get-VirDirInfo -filepath c:\reports
This command will create the report in the following directory: C:\Reports
#>
function Get-VirDirInfo
{
[CmdletBinding()]
[OutputType([int])]
Param
(
#Specify the report file path
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true,
Position = 0)]
[Alias("ReportPath")]
[ValidateNotNullOrEmpty()]
$Filepath,
#query AD instead of the IIS metabase
[Parameter(Mandatory = $false,
ValueFromPipelineByPropertyName = $false,
Position = 1)]
[Alias("ADPropertiesOnly")]
[Switch]$ADProperties,
#specify the computername to connect to. Defaults to the local host.
[Parameter(Mandatory = $false,
Position = 1)]
[ValidateNotNull()]
[ValidateNotNullOrEmpty()]
[string]$ComputerName = $env:COMPUTERNAME,
#optional filter to only query certain CAS servers. Default filter is wildcard.
[Parameter(Mandatory = $false,
Position = 2)]
[ValidateNotNull()]
[ValidateNotNullOrEmpty()]
[string]$Filter = "*"
)
Begin
{
#Open a Remote PS session if none already exists.
if (!(Get-PSSession).ConfigurationName -eq "Microsoft.Exchange")
{
try
{
$sExch = New-PSSession -ConfigurationName Microsoft.Exchange -Name ExchMgmt -ConnectionUri http://$ComputerName/PowerShell/ -Authentication Kerberos
$null = Import-PSSession $sExch
}
catch
{
Write-Warning "Could not connect to Exchange."
Break
}
}
}
Process
{
try
{
$currentServer = (Get-PSSession | ?{ $_.State -eq "Opened" }).ComputerName
$currentServerVersion = Get-ExchangeServer $currentServer | Select AdminDisplayVersion
if (($currentServerVersion.AdminDisplayVersion.Major -eq 15) -and ($currentServerVersion.AdmindisplayVersion.Minor -eq 1) -and ($currentServerVersion.AdmindisplayVersion.Build -ge 466) -and ($currentServerVersion.AdmindisplayVersion.Build -ge "34"))
{
$servers = @(Get-ExchangeServer | ?{ ($_.isClientAccessServer -eq $true) -and (($_.AdminDisplayVersion -like "*15*") -or ($_.AdminDisplayVersion -like "*14*")) -and ($_.Name -like $Filter) } | Select-Object Name, AdminDisplayVersion, ServerRole, Edition)
$runVersion = "2016CU2+"
}
elseif (($currentServerVersion.AdminDisplayVersion.Major -eq 14) -or ($currentServerVersion.AdminDisplayVersion.Major -eq 15))
{
$servers = @(Get-ExchangeServer | ?{ $_.ServerRole -like "*ClientAccess*" -and (($_.AdminDisplayVersion -like "*15*") -or ($_.AdminDisplayVersion -like "*14*") -and ($_.Name -like $Filter)) } | Select-Object Name, AdminDisplayVersion, ServerRole, Edition)
$runVersion = "2016CU2-"
}
}
catch
{
Write-Warning "An error occured: could not connect to one or more Exchange servers".
Break
}
#Define Version Array
$versionArray = @("Microsoft Exchange Server 2010 RTM", "14.0.639.21"),
("Update Rollup 1 for Exchange Server 2010", "14.0.682.1"),
("Update Rollup 2 for Exchange Server 2010", "14.0.689.0"),
("Update Rollup 3 for Exchange Server 2010", "14.0.694.0"),
("Update Rollup 4 for Exchange Server 2010", "14.0.702.1"),
#Exchange 2010 SP1
("Microsoft Exchange Server 2010 SP1", "14.1.218.15"),
("Update Rollup 1 for Exchange Server 2010 SP1", "14.1.255.2"),
("Update Rollup 2 for Exchange Server 2010 SP1", "14.1.270.1"),
("Update Rollup 3 for Exchange Server 2010 SP1", "14.1.289.3"),
("Update Rollup 3-v3 for Exchange Server 2010 SP1", "14.1.289.7"),
("Update Rollup 4 for Exchange Server 2010 SP1", "14.1.323.1"),
("Update Rollup 4-v2 for Exchange Server 2010 SP1", "14.1.323.6"),
("Update Rollup 5 for Exchange Server 2010 SP1", "14.1.339.1"),
("Update Rollup 6 for Exchange Server 2010 SP1", "14.1.355.2"),
("Update Rollup 7 for Exchange Server 2010 SP1", "14.1.421.0"),
("Update Rollup 7-v2 for Exchange Server 2010 SP1", "14.1.421.2"),
("Update Rollup 7-v3 for Exchange Server 2010 SP1", "14.1.421.3"),
("Update Rollup 8 for Exchange Server 2010 SP1", "14.1.438.0"),
#Exchange 2010 SP2
("Microsoft Exchange Server 2010 SP2", "14.2.247.5"),
("Update Rollup 1 for Exchange Server 2010 SP2", "14.2.283.3"),
("Update Rollup 2 for Exchange Server 2010 SP2", "14.2.298.4"),
("Update Rollup 3 for Exchange Server 2010 SP2", "14.2.309.2"),
("Update Rollup 4 for Exchange Server 2010 SP2", "14.2.318.2"),
("Update Rollup 4-v2 for Exchange Server 2010 SP2", "14.2.318.4"),
("Update Rollup 5 for Exchange Server 2010 SP2", "14.2.328.5"),
("Update Rollup 5-v2 for Exchange Server 2010 SP2", "14.2.328.10"),
("Update Rollup 6 for Exchange Server 2010 SP2", "14.2.342.3"),
("Update Rollup 7 for Exchange Server 2010 SP2", "14.2.375.0"),
("Update Rollup 8 for Exchange Server 2010 SP2", "14.2.390.3"),
#Exchange 2010 SP3
("Microsoft Exchange Server 2010 SP3", "14.3.123.4"),
("Update Rollup 1 for Exchange Server 2010 SP3", "14.3.146.0"),
("Update Rollup 2 for Exchange Server 2010 SP3", "14.3.158.1"),
("Update Rollup 3 for Exchange Server 2010 SP3", "14.3.169.1"),
("Update Rollup 4 for Exchange Server 2010 SP3", "14.3.174.1"),
("Update Rollup 5 for Exchange Server 2010 SP3", "14.3.181.6"),
("Update Rollup 6 for Exchange Server 2010 SP3", "14.3.195.1"),
#Exchange 2013
("Exchange Server 2013 Cumulative Update 1 (CU1)", "15.0.620.29"),
("Exchange Server 2013 Cumulative Update 2 (CU2)", "15.0.712.22"),
("Exchange Server 2013 Cumulative Update 2 (CU2-v2)", "15.0.712.24"),
("Exchange Server 2013 Cumulative Update 3 (CU3)", "15.0.775.38"),
("Exchange Server 2013 Cumulative Update 4 (SP1 - CU4)", "15.0.847.32"),
("Exchange Server 2013 Cumulative Update 5 (CU5)", "15.0.913.22"),
("Exchange Server 2013 Cumulative Update 6 (CU6)", "15.0.995.29"),
("Exchange Server 2013 Cumulative Update 7 (CU7)", "15.0.1044.25"),
("Exchange Server 2013 Cumulative Update 8 (CU8)", "15.0.1076.9"),
("Exchange Server 2013 Cumulative Update 9 (CU9)", "15.0.1104.5"),
("Exchange Server 2013 Cumulative Update 10 (CU10)", "15.0.1130.7"),
("Exchange Server 2013 Cumulative Update 11 (CU11)", "15.0.1156.6"),
("Exchange Server 2013 Cumulative Update 12 (CU12)", "15.0.1178.4"),
("Exchange Server 2013 Cumulative Update 13 (CU13)", "15.0.1210.3"),
#Exchange 2016
("Exchange Server 2016 RTM", "15.1.225.42"),
("Exchange Server 2016 Cumulative Update 1", "15.1.396.30"),
("Exchange Server 2016 Cumulative Update 2", "15.1.466.34")
#HTML headers
$html += "<html>"
$html += "<head>"
$html += "<style type='text/css'>"
$html += "body {font-family:verdana;font-size:10pt}"
$html += "H1 {font-family:verdana;font-size:12pt}"
$html += "table {border:1px solid #000000;font-family:verdana; font-size:10pt;cellspacing:1;cellpadding:0}"
$html += "tr.color {background-color:#00A2E8;color:#FFFFFF;font-weight:bold}"
$html += "</style>"
$html += "</head>"
$html += "<body>"
#Report Legend
$html += "Get-VirDirInfo.ps1<br/>"
$html += "<b>Report generated on: </b>" + (get-date).DateTime
#Add warning that the script pulled only the ADProperties
if ($ADProperties)
{
$html += "<br/><b><font color='red'>Warning: The script was run using the -ADPropertiesOnly switch and might not show all information</font></b>"
}
$html += "<br/><br/>"
#General Server Info
$html += "<h1>General Client Access Server Information</h1>"
$html += "<table border='1'>"
$html += "<tr class='color'>"
$html += "<td>Server</td><td>Exchange Version</td><td>Roles</td><td>Edition</td>"
$html += "</tr>"
$i = 0
foreach ($server in $servers)
{
$build = [string]$server.AdminDisplayVersion.Major + "." + $server.AdminDisplayVersion.Minor + "." + $server.AdminDisplayVersion.Build + "." + $server.AdminDisplayVersion.Revision
for ($n = 0; $n -lt $versionArray.count; $n++)
{
if ($build -eq $versionArray[$n][1])
{
$version = $versionArray[$n][0]
}
}
$html += "<tr>"
$html += "<td>" + $server.name + "</td>"
$html += "<td>" + $version + "</td>"
$html += "<td>" + $server.ServerRole + "</td>"
$html += "<td>" + $server.Edition + "</td>"
$html += "</tr>"
}
$html += "</table>"
#Autodiscover
$html += "<br/><br/>"
$html += "<h1>Autodiscover</h1>"
$html += "<table border='1'>"
$html += "<tr class='color'>"
$html += "<td>Server</td><td>Internal Uri</td><td>InternalURL</td><td>ExternalUrl</td><td>Auth. (Int.)</td><td>Auth. (Ext.)</td><td>Site Scope</td><td>Last modified on:</td>"
$html += "</tr>"
$i = 0
foreach ($server in $servers)
{
$i++
Write-Progress -Activity "Getting Autodiscover URL information" -Status "Progress:" -PercentComplete (($i / $servers.count) * 100)
if ($runVersion -eq "2016CU2+")
{
$autodresult = Get-ClientAccessService -Identity $server.name | Select Name, AutodiscoverServiceInternalUri, AutoDiscoverSiteScope
}
else
{
$autodresult = Get-ClientAccessServer -Identity $server.name | Select Name, AutodiscoverServiceInternalUri, AutoDiscoverSiteScope
}
if ($ADProperties)
{
$autodvirdirresult = Get-AutodiscoverVirtualDirectory -Server $server.name -ADPropertiesOnly | Select InternalUrl, ExternalUrl, InternalAuthenticationMethods, ExternalAuthenticationMethods, WhenChanged
}
else
{
$autodvirdirresult = Get-AutodiscoverVirtualDirectory -Server $server.name | Select InternalUrl, ExternalUrl, InternalAuthenticationMethods, ExternalAuthenticationMethods, WhenChanged
}
$autodhtml += "<tr>"
$autodhtml += "<td>" + $autodresult.Name + "</td>"
$autodhtml += "<td>" + $autodresult.AutodiscoverServiceInternalUri + "</td>"
$autodhtml += "<td>" + $autodvirdirresult.InternalURL.absoluteURI + "</td>"
$autodhtml += "<td>" + $autodvirdirresult.ExternalURL.absoluteURI + "</td>"
$autodhtml += "<td>" + $autodvirdirresult.InternalAuthenticationMethods + "</td>"
$autodhtml += "<td>" + $autodvirdirresult.ExternalAuthenticationMethods + "</td>"
$autodhtml += "<td>" + $autodresult.AutoDiscoverSiteScope + "</td>"
$autodhtml += "<td>" + $autodvirdirresult.WhenChanged + "</td>"
$autodhtml += "</tr>"
Clear-Variable -Name autodresult, autodvirdirresult
}
$html += $autodhtml
$html += "</table>"
#Outlook Web App (OWA)
$html += "<br/><br/>"
$html += "<h1>Outlook Web App (OWA):</h1>"
$html += "<table border='1'>"
$html += "<tr class='color'>"
$html += "<td>Server</td><td>Name</td><td>InternalURL</td><td>ExternalUrl</td><td>Int. Auth.</td><td>Last modified on:</td>"
$html += "</tr>"
$i = 0
foreach ($server in $servers)
{
$i++
Write-Progress -Activity "Getting OWA virtual directory information" -Status "Progress:" -PercentComplete (($i / $servers.count) * 100)
if ($ADProperties)
{
$owaresult = Get-OWAVirtualDirectory -server $server.name -AdPropertiesOnly | Select Name, Server, InternalUrl, ExternalUrl, WhenChanged, InternalAuthenticationMethods
}
else
{
$owaresult = Get-OWAVirtualDirectory -server $server.name | Select Name, Server, InternalUrl, ExternalUrl, WhenChanged, InternalAuthenticationMethods
}
$owahtml += "<tr>"
$owahtml += "<td>" + $owaresult.Server + "</td>"
$owahtml += "<td>" + $owaresult.Name + "</td>"
$owahtml += "<td>" + $owaresult.InternalURL.absoluteURI + "</td>"
$owahtml += "<td>" + $owaresult.ExternalURL.absoluteURI + "</td>"
$owahtml += "<td>" + $owaresult.InternalAuthenticationMethods + "</td>"
$owahtml += "<td>" + $owaresult.WhenChanged + "</td>"
$owahtml += "</tr>"
Clear-Variable -Name owaresult
}
$html += $owahtml
$html += "</table>"
#Exchange Control Panel (ECP)
$html += "<br/><br/>"
$html += "<h1>Exchange Control Panel (ECP):</h1>"
$html += "<table border='1'>"
$html += "<tr class='color'>"
$html += "<td>Server</td><td>Name</td><td>InternalURL</td><td>ExternalUrl</td><td>Int. Auth.</td><td>Last modified on:</td>"
$html += "</tr>"
$i = 0
foreach ($server in $servers)
{
$i++
Write-Progress -Activity "Getting ECP virtual directory information" -Status "Progress:" -PercentComplete (($i / $servers.count) * 100)
if ($ADProperties)
{
$ecpresult = Get-ECPVirtualDirectory -server $server.name -ADPropertiesOnly | Select Name, Server, InternalUrl, ExternalUrl, WhenChanged, InternalAuthenticationMethods
}
else
{
$ecpresult = Get-ECPVirtualDirectory -server $server.name | Select Name, Server, InternalUrl, ExternalUrl, WhenChanged, InternalAuthenticationMethods
}
$ecphtml += "<tr.color>"
$ecphtml += "<td>" + $ecpresult.Server + "</td>"
$ecphtml += "<td>" + $ecpresult.Name + "</td>"
$ecphtml += "<td>" + $ecpresult.InternalURL.absoluteURI + "</td>"
$ecphtml += "<td>" + $ecpresult.ExternalURL.absoluteURI + "</td>"
$ecphtml += "<td>" + $ecpresult.InternalAuthenticationMethods + "</td>"
$ecphtml += "<td>" + $ecpresult.WhenChanged + "</td>"
$ecphtml += "</tr>"
Clear-Variable -Name ecpresult
}
$html += $ecphtml
$html += "</table>"
#Outlook Anywhere
$html += "<br/><br/>"
$html += "<h1>Outlook Anywhere:</h1>"
$html += "<table border='1'>"
$html += "<tr class='color'>"
$html += "<td>Server</td><td>Internal Hostname</td><td>External Hostname</td><td>Auth.(Int.)</td><td>Auth. (Ext.)</td><td>Auth. IIS</td><td>Last modified on:</td>"
$html += "</tr>"
$i = 0
foreach ($server in $servers)
{
$i++
Write-Progress -Activity "Getting Outlook Anywhere Information" -Status "Progress:" -PercentComplete (($i / $servers.count) * 100)
if ($ADProperties)
{
$oaresult = Get-OutlookAnywhere -server $server.name -ADPropertiesOnly | Select Name, Server, InternalHostname, ExternalHostname, ExternalClientAuthenticationMethod, InternalClientAuthenticationMethod, IISAuthenticationMethods, WhenChanged
}
else
{
$oaresult = Get-OutlookAnywhere -server $server.name | Select Name, Server, InternalHostname, ExternalHostname, ExternalClientAuthenticationMethod, InternalClientAuthenticationMethod, IISAuthenticationMethods, WhenChanged
}
if ($oaresult -eq $null)
{
$oahtml += "<tr.color>"
$oahtml += "<td>" + $server.name + "</td>"
$oahtml += "<td colspan='6'>"
$oahtml += "Outlook Anywhere isn't enabled."
$oahtml += "</td>"
$oahtml += "</tr>"
}
else
{
$oahtml += "<tr.color>"
$oahtml += "<td>" + $oaresult.Server + "</td>"
$oahtml += "<td>" + $oaresult.InternalHostname + "</td>"
$oahtml += "<td>" + $oaresult.ExternalHostname + "</td>"
$oahtml += "<td>" + $oaresult.InternalClientAuthenticationMethod + "</td>"
$oahtml += "<td>" + $oaresult.ExternalClientAuthenticationMethod + "</td>"
$oahtml += "<td>" + $oaresult.IISAuthenticationMethods + "</td>"
$oahtml += "<td>" + $oaresult.WhenChanged + "</td>"
$oahtml += "</tr>"
}
Clear-Variable oaresult
}
$html += $oahtml
$html += "</table>"
#MAPI/HTTP
$html += "<br/><br/>"
$html += "<h1>MAPI/HTTP:</h1>"
$html += "<table border='1'>"
$html += "<tr class='color'>"
$html += "<td>Server</td><td>Internal URL</td><td>External URL</td><td>Auth.(Int.)</td><td>Auth. (Ext.)</td><td>Auth. IIS</td><td>Last modified on:</td>"
$html += "</tr>"
$i = 0
foreach ($server in $servers)
{
$i++
if (($server.AdminDisplayVersion.Major -eq "15" -and $server.AdminDisplayVersion.Build -ge "847") -or ($server.AdminDisplayVersion.Major -eq "15" -and $server.AdminDisplayVersion.Minor -eq "1"))
{
Write-Progress -Activity "Getting MAPI/HTTP Information" -Status "Progress:" -PercentComplete (($i / $servers.count) * 100)
if ($ADProperties)
{
$mapiresult = Get-MapiVirtualDirectory -server $server.name -ADPropertiesOnly | Select Name, Server, InternalUrl, ExternalUrl, ExternalAuthenticationMethods, InternalAuthenticationMethods, IISAuthenticationMethods, WhenChanged
}
else
{
$mapiresult = Get-MapiVirtualDirectory -server $server.name | Select Name, Server, InternalUrl, ExternalUrl, ExternalAuthenticationMethods, InternalAuthenticationMethods, IISAuthenticationMethods, WhenChanged
}
$mapihtml += "<tr.color>"
$mapihtml += "<td>" + $mapiresult.Server + "</td>"
$mapihtml += "<td>" + $mapiresult.InternalUrl + "</td>"
$mapihtml += "<td>" + $mapiresult.ExternalUrl + "</td>"
$mapihtml += "<td>" + $mapiresult.InternalAuthenticationMethods + "</td>"
$mapihtml += "<td>" + $mapiresult.ExternalAuthenticationMethods + "</td>"
$mapihtml += "<td>" + $mapiresult.IISAuthenticationMethods + "</td>"
$mapihtml += "<td>" + $mapiresult.WhenChanged + "</td>"
$mapihtml += "</tr>"
}
else
{
$mapihtml += "<tr.color>"
$mapihtml += "<td>" + $server.name + "</td>"
$mapihtml += "<td colspan='6'>"
$mapihtml += "Server isn't running Exchange 2013 SP1 or later."
$mapihtml += "</td>"
$mapihtml += "</tr>"
}
Clear-Variable oaresult
}
$html += $mapihtml
$html += "</table>"
#Offline Address Book (OAB)
$html += "<br/><br/>"
$html += "<h1>Offline Address Book (OAB):</h1>"
$html += "<table border='1'>"
$html += "<tr class='color'>"
$html += "<td>Server</td><td>OABs</td><td>Internal URL</td><td>External Url</td><td>Auth.(Int.)</td><td>Auth. (Ext.)</td><td>Last modified on:</td>"
$html += "</tr>"
$i = 0
foreach ($server in $servers)
{
$i++
Write-Progress -Activity "Getting OAB Information" -Status "Progress:" -PercentComplete (($i / $servers.count) * 100)
if ($ADProperties)
{
$oabresult = Get-OABVirtualDirectory -server $server.name -ADPropertiesOnly | Select Server, InternalUrl, ExternalUrl, ExternalAuthenticationMethods, InternalAuthenticationMethods, OfflineAddressBooks, WhenChanged
}
else
{
$oabresult = Get-OABVirtualDirectory -server $server.name | Select Server, InternalUrl, ExternalUrl, ExternalAuthenticationMethods, InternalAuthenticationMethods, OfflineAddressBooks, WhenChanged
}
$oabhtml += "<tr.color>"
$oabhtml += "<td>" + $oabresult.Server + "</td>"
$oabhtml += "<td>" + $oabresult.OfflineAddressBooks + "</td>"
$oabhtml += "<td>" + $oabresult.InternalURL.absoluteURI + "</td>"
$oabhtml += "<td>" + $oabresult.ExternalURL.absoluteURI + "</td>"
$oabhtml += "<td>" + $oabresult.InternalAuthenticationMethods + "</td>"
$oabhtml += "<td>" + $oabresult.ExternalAuthenticationMethods + "</td>"
$oabhtml += "<td>" + $oabresult.WhenChanged + "</td>"
$oabhtml += "</tr>"
Clear-Variable oabresult
}
$html += $oabhtml
$html += "</table>"
#ActiveSync (EAS)
$html += "<br/><br/>"
$html += "<h1>ActiveSync (EAS):</h1>"
$html += "<table border='1'>"
$html += "<tr class='color'>"
$html += "<td>Server</td><td>Internal URL</td><td>External Url</td><td>Auth. (Ext.)</td><td>Last modified on:</td>"
$html += "</tr>"
$i = 0
foreach ($server in $servers)
{
$i++
Write-Progress -Activity "Getting ActiveSync Information" -Status "Progress:" -PercentComplete (($i / $servers.count) * 100)
if ($ADProperties)
{
$easresult = Get-ActiveSyncVirtualDirectory -server $server.name -ADPropertiesOnly | Select Server, InternalUrl, ExternalUrl, ExternalAuthenticationMethods, InternalAuthenticationMethods, WhenChanged
}
else
{
$easresult = Get-ActiveSyncVirtualDirectory -server $server.name | Select Server, InternalUrl, ExternalUrl, ExternalAuthenticationMethods, InternalAuthenticationMethods, WhenChanged
}
$eashtml += "<tr.color>"
$eashtml += "<td>" + $easresult.Server + "</td>"
$eashtml += "<td>" + $easresult.InternalURL.absoluteUri + "</td>"
$eashtml += "<td>" + $easresult.ExternalURL.absoluteUri + "</td>"
$eashtml += "<td>" + $easresult.ExternalAuthenticationMethods + "</td>"
$eashtml += "<td>" + $easresult.WhenChanged + "</td>"
$eashtml += "</tr>"
Clear-Variable easresult
}
$html += $eashtml
$html += "</table>"
#Exchange Web Services (EWS)
$html += "<br/><br/>"
$html += "<h1>Exchange Web Services(EWS):</h1>"
$html += "<table border='1'>"
$html += "<tr class='color'>"
$html += "<td>Server</td><td>Internal URL</td><td>External Url</td><td>Auth. (Int.)</td><td>Auth. (Ext.)</td><td>MRS Proxy Enabled</td><td>Last modified on:</td>"
$html += "</tr>"
$i = 0
foreach ($server in $servers)
{
$i++
Write-Progress -Activity "Getting Web Services Information" -Status "Progress:" -PercentComplete (($i / $servers.count) * 100)
if ($ADProperties)
{
$ewsresult = Get-WebServicesVirtualDirectory -server $server.name -ADPropertiesOnly | Select Server, InternalUrl, ExternalUrl, ExternalAuthenticationMethods, InternalAuthenticationMethods, MRSProxyEnabled, WhenChanged
}
else
{
$ewsresult = Get-WebServicesVirtualDirectory -server $server.name | Select Server, InternalUrl, ExternalUrl, ExternalAuthenticationMethods, InternalAuthenticationMethods, MRSProxyEnabled, WhenChanged
}
$ewshtml += "<tr.color>"
$ewshtml += "<td>" + $ewsresult.Server + "</td>"
$ewshtml += "<td>" + $ewsresult.InternalURL.absoluteUri + "</td>"
$ewshtml += "<td>" + $ewsresult.ExternalURL.absoluteUri + "</td>"
$ewshtml += "<td>" + $ewsresult.InternalAuthenticationMethods + "</td>"
$ewshtml += "<td>" + $ewsresult.ExternalAuthenticationMethods + "</td>"
$ewshtml += "<td>" + $ewsresult.MRSProxyEnabled + "</td>"
$ewshtml += "<td>" + $ewsresult.WhenChanged + "</td>"
$ewshtml += "</tr>"
Clear-Variable easresult
}
$html += $ewshtml
$html += "</table>"
try
{
$html | Out-File $filepath"\virdirinfo_"$(get-date -Format d-MM-yyyy_HH\hmm\mss\s)".html"
Write-Host "Successfully created"$filepath"\virdirinfo_"$(get-date -Format d-MM-yyyy_HH\hmm\mss\s)".html" -ForegroundColor Green
}
catch
{
Write-Warning "Couldn't save "$filepath"\virdirinfo_"$( get-date -Format d-MM-yyyy_HH\hmm\mss\s )".html"
}
}
End
{
Get-PSSession | ?{ $_.ComputerName -like "$server" } | Remove-PSSession
Clear-Variable Owahtml, Owaresult, html, servers
}
}