7
7
THIS CODE IS MADE AVAILABLE AS IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE
8
8
RISK OF THE USE OR THE RESULTS FROM THE USE OF THIS CODE REMAINS WITH THE USER.
9
9
10
- Version 2.1 2019-09-26
10
+ Version 2.2 January 2020
11
11
12
12
Based on the original 1.6.2 version by Steve Goodman
13
13
65
65
66
66
IMPORTANT NOTE: The script requires WMI and Remote Registry access to Exchange servers from the server
67
67
it is run from to determine OS version, Update Rollup, Exchange 2007/2003 cluster and DB size information.
68
-
69
- Updates
70
- - 2.1 Table header label updated for a more consistent labeling
71
- - 2.0 Initial Release
72
68
73
69
. LINK
74
70
http://scripts.granikos.eu
94
90
. PARAMETER ServerFilter
95
91
Use a text based string to filter Exchange Servers by, e.g., NL-*
96
92
Note the use of the wildcard (*) character to allow for multiple matches.
93
+
94
+ . PARAMETER ShowDriveNames
95
+ Include drive names of EDB file path and LOG file folder in database report table
97
96
98
97
. EXAMPLE
99
98
Generate the HTML report
102
101
. EXAMPLE
103
102
Generate am HTML report and send the result as HTML email with attachment to the specified recipient using a dedicated smart host
104
103
.\Get-ExchangeEnvironmentReport.ps1 -HTMReport ExchangeEnvironment.html -SendMail -ViewEntireForet $true -MailFrom roaster@mcsmemail.de -MailTo grillmaster@mcsmemail.de -MailServer relay.mcsmemail.de
105
-
104
+
105
+ . EXAMPLE
106
+ Generate the HTML report including EDB and LOG drive names
107
+ .\Get-ExchangeEnvironmentReport.ps1 -ShowDriveNames -HTMLReport .\report.html
106
108
#>
107
109
[CmdletBinding ()]
108
110
param (
@@ -112,13 +114,16 @@ param(
112
114
[string ]$MailTo = ' ' ,
113
115
[string ]$MailServer = ' ' ,
114
116
[bool ]$ViewEntireForest = $true ,
115
- [string ]$ServerFilter = ' *'
117
+ [string ]$ServerFilter = ' *' ,
118
+ [switch ]$ShowDriveNames
116
119
)
117
120
118
121
# Warning Limits, adjust as needed
119
122
$MinFreeDiskspace = 10 # Mark free space less than this value (%) in red
120
123
$MaxDatabaseSize = 250 # Mark database larger than this value (GB) in red
121
124
125
+ # Default variables
126
+ $NotAvailable = ' N/A'
122
127
123
128
# Sub-Function to Get Database Information. Shorter than expected..
124
129
function Get-DatabaseAvailabilityGroupInformation {
@@ -148,6 +153,23 @@ function Get-DatabaseInformation {
148
153
# Circular Logging, Last Full Backup
149
154
if ($Database.CircularLoggingEnabled ) { $CircularLoggingEnabled = ' Yes' } else { $CircularLoggingEnabled = ' No' }
150
155
if ($Database.LastFullBackup ) { $LastFullBackup = $Database.LastFullBackup.ToString () } else { $LastFullBackup = ' Not Available' }
156
+
157
+ # Drive Letter, GitHub issue #4
158
+ $DriveNameEdb = ' '
159
+ try {
160
+ $DriveNameEdb = $Database.EdbFilePath.DriveName
161
+ }
162
+ catch {
163
+ $DriveNameEdb = $NotAvailable
164
+ }
165
+
166
+ $DriveNameLog = ' '
167
+ try {
168
+ $DriveNameLog = $Database.LogFolderPath.DriveName
169
+ }
170
+ catch {
171
+ $DriveNameLog = $NotAvailable
172
+ }
151
173
152
174
# Mailbox Average Sizes
153
175
$MailboxStatistics = [array ]($ExchangeEnvironment.Servers [$Database.Server.Name ].MailboxStatistics | Where-Object {$_.Database -eq $Database.Identity })
@@ -258,6 +280,8 @@ function Get-DatabaseInformation {
258
280
CopyCount = $CopyCount
259
281
FreeLogDiskSpace = $FreeLogDiskSpace
260
282
FreeDatabaseDiskSpace = $FreeDatabaseDiskSpace
283
+ DriveNameEdb = $DriveNameEdb
284
+ DriveNameLog = $DriveNameLog
261
285
}
262
286
}
263
287
@@ -304,7 +328,6 @@ function Get-ExchangeServerInformation {
304
328
$MaxPrefDatabases = 0
305
329
$MaxActiveDatabases = 0
306
330
$NotSet = ' --'
307
- $NotAvailable = ' N/A'
308
331
309
332
# Get WMI Information: Operatin System
310
333
$tWMI = Get-WmiObject - Class Win32_OperatingSystem - ComputerName $ExchangeServer.Name - ErrorAction SilentlyContinue
@@ -377,7 +400,7 @@ function Get-ExchangeServerInformation {
377
400
}
378
401
379
402
if ($ExchangeMajorVersion -ge 14 ) {
380
- $mailboxServer = Get-MailboxServer $ ($ExchangeServer.Name )
403
+ $mailboxServer = Get-MailboxServer - Identity $ ($ExchangeServer.Name )
381
404
382
405
# 2019-05-20 TST Gather max active/max preferred database config
383
406
if ($ExchangeMajorVersion -lt 15 ) {
@@ -755,7 +778,7 @@ function Get-HtmlOverview {
755
778
$AlternateRow = 0
756
779
757
780
foreach ($Server in $Servers.Value ) {
758
- $Output += " <tr"
781
+ $Output += ' <tr'
759
782
760
783
if ($AlternateRow ) {
761
784
$Output += " class='alternaterow'"
@@ -774,25 +797,25 @@ function Get-HtmlOverview {
774
797
$Output += " </td><td>$ ( $ExVersionStrings [" $ ( $Server.ExchangeMajorVersion ) .$ ( $Server.ExchangeSPLevel ) " ].Long) "
775
798
776
799
if ($Server.RollupLevel -gt 0 ) {
777
- $Output += " UR$ ( $ Server.RollupLevel ) "
800
+ $Output += ( ' UR{0} ' -f $ Server.RollupLevel )
778
801
if ($Server.RollupVersion ) {
779
- $Output += " $ ( $ Server.RollupVersion ) "
802
+ $Output += ( ' {0} ' -f $ Server.RollupVersion )
780
803
}
781
804
}
782
805
783
- $Output += " </td>"
806
+ $Output += ' </td>'
784
807
785
808
$ExchangeEnvironment.TotalServersByRole.GetEnumerator () | Sort-Object - Property Name | ForEach-Object {
786
- $Output += " <td"
809
+ $Output += ' <td'
787
810
if ($Server.Roles -contains $_.Key ) {
788
811
$Output += " class='roledata'>"
789
812
}
790
813
else {
791
- $Output += " />"
814
+ $Output += ' />'
792
815
}
793
816
794
817
if (($_.Key -eq ' ClusteredMailbox' -or $_.Key -eq ' Mailbox' -or $_.Key -eq ' BE' ) -and $Server.Roles -contains $_.Key ) {
795
- $Output += " $ ( $Server.Mailboxes ) </td> "
818
+ $Output += ( ' {0}</td> ' -f $Server.Mailboxes )
796
819
}
797
820
}
798
821
@@ -801,7 +824,7 @@ function Get-HtmlOverview {
801
824
$Output += " <td align="" center"" >$ ( $Server.MaximumPreferredDatabases ) / $ ( $Server.MaximumActiveDatabases ) </td><td>$ ( $Server.OSVersion ) </td><td>$ ( $Server.OSServicePack ) </td></tr>"
802
825
}
803
826
else {
804
- $Output += " <td align="" center"" >Not Applicable</td><td>$ ( $Server .OSVersion ) </td><td>$ ( $Server .OSServicePack ) </td></tr>"
827
+ $Output += ( ' <td align=""center"">Not Applicable</td><td>{0} </td><td>{1} </td></tr>' -f $Server .OSVersion , $Server .OSServicePack )
805
828
}
806
829
807
830
# $Output+="<td>$($Server.OSVersion)</td><td>$($Server.OSServicePack)</td></tr>";
@@ -821,14 +844,13 @@ function Get-HtmlDatabaseInformationTable {
821
844
)
822
845
823
846
# Only Show Archive Mailbox Columns, Backup Columns and Circ Logging if at least one DB has an Archive mailbox, backed up or Cir Log enabled.
824
- $ShowArchiveDBs = $False
825
- $ShowLastFullBackup = $False
826
- $ShowCircularLogging = $False
827
- $ShowStorageGroups = $False
828
- $ShowCopies = $False
829
- $ShowFreeDatabaseSpace = $False
830
- $ShowFreeLogDiskSpace = $False
831
-
847
+ $ShowArchiveDBs = $False
848
+ $ShowLastFullBackup = $False
849
+ $ShowCircularLogging = $False
850
+ $ShowStorageGroups = $False
851
+ $ShowCopies = $False
852
+ $ShowFreeDatabaseSpace = $False
853
+ $ShowFreeLogDiskSpace = $False
832
854
833
855
foreach ($Database in $Databases ) {
834
856
if ($Database.ArchiveMailboxCount -gt 0 ) {
@@ -854,17 +876,19 @@ function Get-HtmlDatabaseInformationTable {
854
876
}
855
877
}
856
878
857
- $Output = " <table class='databases'>
858
- <tr class='databases'>
859
- <th>Server</th>"
879
+ $Output = " <table class='databases'>"
880
+
881
+ # region database table header
882
+ $Output += " <tr class='databases'>
883
+ <th>Server</th>"
860
884
861
885
if ($ShowStorageGroups ) {
862
- $Output += " <th>Storage Group</th>"
886
+ $Output += ' <th>Storage Group</th>'
863
887
}
864
888
865
- $Output += " <th>Database Name</th>
889
+ $Output += ' <th>Database Name</th>
866
890
<th>Standard Mailboxes</th>
867
- <th>Av. Mailbox Size</th>"
891
+ <th>Av. Mailbox Size</th>'
868
892
869
893
if ($ShowArchiveDBs ) {
870
894
$Output += ' <th>Archive Mailboxes</th><th>Av. Archive Size</th>'
@@ -887,12 +911,19 @@ function Get-HtmlDatabaseInformationTable {
887
911
if ($ShowCopies ) {
888
912
$Output += ' <th>DB Copies (n)</th>'
889
913
}
914
+
915
+ # Drive names, issue #4
916
+ if ($ShowDriveNames ) {
917
+ $Output += ' <th>EDB / LOG</th>'
918
+ }
890
919
891
920
$Output += ' </tr>'
921
+ # endregion
922
+
892
923
$AlternateRow = 0
893
924
894
925
foreach ($Database in $Databases ) {
895
- $Output += " <tr"
926
+ $Output += ' <tr'
896
927
897
928
if ($AlternateRow ) {
898
929
$Output += " class='alternaterow'"
@@ -954,17 +985,24 @@ function Get-HtmlDatabaseInformationTable {
954
985
if ($ShowCopies ) {
955
986
$Output += " <td>$ ( $Database.Copies | ForEach-Object {$_ }) ($ ( $Database.CopyCount ) )</td>"
956
987
}
988
+
989
+ # Drive names, issue #4
990
+ if ($ShowDriveNames ) {
991
+ $Output += " <td class='center'>$ ( " {0} / {1}" -f $Database.DriveNameEdb , $Database.DriveNameLog ) </td>"
992
+ }
957
993
$Output += ' </tr>'
958
994
}
959
995
960
996
$Output += ' </table><br />'
961
997
962
- $Output += (" <p class='dagtablefooter'>Maximum mailbox database size: {0} GB<br/>Minumum free disk space: {1}%</p>" -f $MaxDatabaseSize , $MinFreeDiskspace )
998
+ $Output += ' <p class="dagtablefooter">Explanation</p>'
999
+ $Output += (" <p class='dagtablefooter'>Maximum mailbox database size: {0} GB<br/>Minimum free disk space: {1}%</p>" -f $MaxDatabaseSize , $MinFreeDiskspace )
963
1000
964
1001
$Output
965
1002
}
966
1003
967
1004
function Get-HtmlReportHeader {
1005
+ [CmdletBinding ()]
968
1006
param (
969
1007
$ExchangeEnvironment ,
970
1008
$Path
@@ -979,23 +1017,20 @@ function Get-HtmlReportHeader {
979
1017
$UseCss = $true
980
1018
981
1019
# Header
982
- $Output = "
1020
+ $Output = '
983
1021
<html>
984
1022
<body>
985
- <title>Exchange Environment Report</title>"
1023
+ <title>Exchange Environment Report</title>'
986
1024
987
1025
if ($UseCss -and (Test-Path - Path (Join-Path - Path (Split-Path - Parent $Path ) - ChildPath $CssFileName ))) {
988
1026
$Output += " <style type="" text/css"" >$ ( Get-Content - Path (Join-Path - Path (Split-Path - Parent $Path ) - ChildPath $CssFileName )) </style>"
989
1027
}
990
1028
991
-
992
- $Output += (" <font size="" 1"" face="" Segoe UI,Arial,sans-serif"" >
993
- <h2 align="" center"" >Exchange Environment Report</h3>
994
- <h4 align="" center"" >Generated {0}</h5>
995
- </font>
1029
+ $Output += (" <h2 align="" center"" >Exchange Environment Report</h2><h3 align="" center"" >Organization: {3}</h3>
1030
+ <h4 align="" center"" >Generated {0}</h4>
996
1031
<table class='header'>
997
1032
<tr class='header'>
998
- <th colspan="" {1}"" class='header'>{2}</th>" -f (Get-Date - Format $DateLabelFormat ), $ExchangeEnvironment.TotalMailboxesByVersion.Count , $LabelTotalServers )
1033
+ <th colspan="" {1}"" class='header'>{2}</th>" -f (Get-Date - Format $DateLabelFormat ), $ExchangeEnvironment.TotalMailboxesByVersion.Count , $LabelTotalServers , $ExchangeEnvironment .OrganizationName )
999
1034
1000
1035
if ($ExchangeEnvironment.RemoteMailboxes ) {
1001
1036
$Output += (" <th colspan="" {0}"" class='header'>{1}</th>" -f ($ExchangeEnvironment.TotalMailboxesByVersion.Count + 2 ), $LabelTotalMailboxes )
@@ -1036,12 +1071,13 @@ function Get-HtmlReportHeader {
1036
1071
$ExchangeEnvironment.TotalServersByRole.GetEnumerator ()| Sort-Object - Property Name| ForEach-Object {$Output += " <td class='headerdata'>$ ( $_.Value ) </td>" }
1037
1072
1038
1073
# $Output+="</tr><tr><tr></table><br>"
1039
- $Output += " </tr></table><!-- End --><br />"
1074
+ $Output += ' </tr></table><!-- End --><br />'
1040
1075
1041
1076
$Output
1042
1077
}
1043
1078
1044
1079
function Get-HtmlDagHeader {
1080
+ [CmdletBinding ()]
1045
1081
param (
1046
1082
$DAG
1047
1083
)
@@ -1055,7 +1091,7 @@ function Get-HtmlDagHeader {
1055
1091
1056
1092
$DAG.Members | ForEach-Object { $Output += (' {0} ' -f $_ ) }
1057
1093
1058
- $Output += " </td></tr></table><br />"
1094
+ $Output += ' </td></tr></table><br />'
1059
1095
1060
1096
$Output
1061
1097
}
@@ -1157,6 +1193,7 @@ $ExchangeEnvironment = @{
1157
1193
Servers = @ {}
1158
1194
DAGs = @ ()
1159
1195
NonDAGDatabases = @ ()
1196
+ OrganizationName = ' '
1160
1197
}
1161
1198
1162
1199
# 1.5.7 Exchange Major Version String Mapping
@@ -1265,6 +1302,10 @@ else {
1265
1302
# 2.3 Populate Information we know
1266
1303
$ExchangeEnvironment.Add (' TotalMailboxes' , $Mailboxes.Count + $ExchangeEnvironment.RemoteMailboxes )
1267
1304
1305
+ # 2.4 Organizational Info
1306
+
1307
+ $ExchangeEnvironment.OrganizationName = (Get-OrganizationConfig ).Name
1308
+
1268
1309
# 3 Process High-Level Exchange Information
1269
1310
1270
1311
# 3.1 Collect Exchange Server Information
@@ -1367,8 +1408,8 @@ if ($ExchangeEnvironment.NonDAGDatabases.Count) {
1367
1408
1368
1409
Show-ProgressBar - PercentComplete 80 - Status ' Writing HTML Non-DAG Database Information' - Stage 4
1369
1410
1370
- $Output += " <table class="" dagsummary" " >
1371
- <tr class="" dagsummarynondag"" ><th>Mailbox Databases (Non-DAG)</th></table>"
1411
+ $Output += ' <table class="dagsummary">
1412
+ <tr class="dagsummarynondag"><th>Mailbox Databases (Non-DAG)</th></table>'
1372
1413
1373
1414
# Get Table HTML for non-DAG databases
1374
1415
$Output += Get-HtmlDatabaseInformationTable - Databases $ExchangeEnvironment.NonDAGDatabases
0 commit comments