{"id":961,"date":"2020-02-18T12:52:55","date_gmt":"2020-02-18T12:52:55","guid":{"rendered":"http:\/\/ihni.uk\/?p=961"},"modified":"2020-02-18T12:52:55","modified_gmt":"2020-02-18T12:52:55","slug":"exchange-environmental-check","status":"publish","type":"post","link":"https:\/\/ihni.uk\/?p=961","title":{"rendered":"Powershell &#8211; Exchange Environmental Check"},"content":{"rendered":"<p>I have adapted the \u201cModern Exchange Environment Check\u201d from\u00a0<a href=\"https:\/\/web.archive.org\/web\/20180901155222\/http:\/\/www.careexchange.in\/wp-content\/uploads\/2015\/09\/ModernExchangeEnvironmentReport.htm\">Satheshwaran Manoharan<\/a>\u00a0and for use on a Exchange Server 2016 environment.<br \/>\nAdded to the already excelent script is the following<\/p>\n<ul>\n<li>Section Headers<\/li>\n<li>MailboxDB provisioning Status<\/li>\n<li>Whitespace check<\/li>\n<li>Exchange Log Dir Size<\/li>\n<li>Exchange Server Drive Space<\/li>\n<li>Mail Queue Checks<\/li>\n<li>House Keeping of created files<\/li>\n<\/ul>\n<p><span id=\"more-974\"><\/span><br \/>\nI feel that this is now a more complete report of the Exchange Server environment and the servers it runs upon.<!--more--><\/p>\n<p>I had toyed with adding the \u201c10 largest user Mailboxes\u201d to the account, but this takes a considerable time to run and would be better suited to ad-hoc reporting.<\/p>\n<p>[CC lang=\u2019powershell\u2019]<br \/>\n# Requires -version 2 &#8211; Runs in Exchange Management Shell<\/p>\n<p># It displays Complete Exchange Environment Information in a modern HTML. It covers only Exchange 2010 or later.<\/p>\n<p># Set Working Dir<br \/>\nPush-Location\u00a0(Split-Path\u00a0-path\u00a0$MyInvocation.MyCommand.Definition\u00a0-Parent)<\/p>\n<p>#Add Exchange Server snapin if not already loaded<\/p>\n<p>if (!(Get-PSSnapin | where {$_.Name -eq &#8220;Microsoft.Exchange.Management.PowerShell.E2010&#8221;}))<br \/>\n{<br \/>\nAdd-PSSnapin\u00a0Microsoft.Exchange.Management.PowerShell.E2010\u00a0-ErrorAction\u00a0SilentlyContinue<br \/>\n}<br \/>\nWrite-Progress\u00a0-Activity\u00a0&#8220;Date&#8221;\u00a0-status\u00a0&#8220;Collecting Dates info&#8221;<br \/>\n$Date\u00a0=\u00a0Get-date\u00a0-ErrorAction\u00a0SilentlyContinue<\/p>\n<p># &#8212;&#8211; Settings &#8212;-<\/p>\n<p>#Should the Script Open the HTML File locally on Finishing the script &#8211; Say Yes &#8211; if you wish to<\/p>\n<p>$Openhtmllocally\u00a0=\u00a0&#8220;No&#8221;<\/p>\n<p>Write-Progress\u00a0-Activity\u00a0&#8220;Email Settings&#8221;\u00a0-status\u00a0&#8220;Storing Email Settings&#8221;<br \/>\n## &#8212;&#8211; Email &#8212;-Fill in with your details<\/p>\n<p>$EmailTo\u00a0=\u00a0&#8220;youremail@yourdomain.com&#8221;<br \/>\n$EmailFrom\u00a0=\u00a0&#8220;ExchangeChecks@yourdomain.com&#8221;<br \/>\n$EmailSubject\u00a0=\u00a0&#8220;Exchange Status Report $Date&#8221;<br \/>\n$SmtpServer\u00a0=\u00a0&#8220;mail.yourdomain.com&#8221;<br \/>\n$Date\u00a0= (Get-Date\u00a0-format\u00a0&#8220;dd-MM-yyyy&#8221;)<br \/>\n$Attachment\u00a0=\u00a0&#8220;.\\output\\ModernExchangeEnvironmentReport($date).htm&#8221;<\/p>\n<p># &#8212;&#8211; Settings &#8212;-<\/p>\n<p>#Collecting Environment Information<br \/>\nWrite-Progress\u00a0-Activity\u00a0&#8220;Exchange Servers&#8221;\u00a0-status\u00a0&#8220;Collecting Exchange Servers info&#8221;<br \/>\n$ExchangeServers\u00a0=\u00a0Get-ExchangeServer\u00a0-ErrorAction\u00a0SilentlyContinue<\/p>\n<p>Write-Progress\u00a0-Activity\u00a0&#8220;Mailboxes&#8221;\u00a0-status\u00a0&#8220;Collecting Collecting Mailboxes info&#8221;<br \/>\n$mailboxes\u00a0=\u00a0Get-mailbox\u00a0-ResultSize\u00a0Unlimited\u00a0-ErrorAction\u00a0SilentlyContinue<\/p>\n<p>Write-Progress\u00a0-Activity\u00a0&#8220;Databases&#8221;\u00a0-status\u00a0&#8220;Collecting Databases info&#8221;<br \/>\n$Databases\u00a0=\u00a0Get-mailboxdatabase\u00a0-Status\u00a0-ErrorAction\u00a0SilentlyContinue<\/p>\n<p>Write-Progress\u00a0-Activity\u00a0&#8220;DAG&#8221;\u00a0-status\u00a0&#8220;Collecting DAG info&#8221;<br \/>\n$DAGS\u00a0=\u00a0Get-DatabaseAvailabilityGroup\u00a0-ErrorAction\u00a0SilentlyContinue<\/p>\n<p>Write-Progress\u00a0-Activity\u00a0&#8220;DistributionGroups&#8221;\u00a0-status\u00a0&#8220;Collecting DistributionGroup info&#8221;<br \/>\n$DistributionGroups\u00a0=\u00a0Get-DistributionGroup\u00a0-ResultSize\u00a0Unlimited\u00a0-ErrorAction\u00a0SilentlyContinue<\/p>\n<p>Write-Progress\u00a0-Activity\u00a0&#8220;DynamicDistributionGroups&#8221;\u00a0-status\u00a0&#8220;Collecting DynamicDistributionGroup info&#8221;<br \/>\n$DynamicGroups\u00a0=\u00a0Get-DynamicDistributionGroup\u00a0-ResultSize\u00a0Unlimited\u00a0-ErrorAction\u00a0SilentlyContinue<\/p>\n<p>Write-Progress\u00a0-Activity\u00a0&#8220;MailContacts&#8221;\u00a0-status\u00a0&#8220;Collecting MailContacts info&#8221;<br \/>\n$MailContacts\u00a0=\u00a0Get-MailContact\u00a0-ResultSize\u00a0Unlimited\u00a0-ErrorAction\u00a0SilentlyContinue<\/p>\n<p>Write-Progress\u00a0-Activity\u00a0&#8220;Public Folder&#8221;\u00a0-status\u00a0&#8220;Collecting Public Folder Mailboxes info&#8221;<br \/>\n$PFmailboxes\u00a0=\u00a0Get-mailbox\u00a0-PublicFolder\u00a0-ResultSize\u00a0Unlimited\u00a0-ErrorAction\u00a0SilentlyContinue<\/p>\n<p>Write-Progress\u00a0-Activity\u00a0&#8220;SendConnectors&#8221;\u00a0-status\u00a0&#8220;Collecting SendConnectors info&#8221;<br \/>\n$SendConnectors\u00a0=\u00a0Get-SendConnector\u00a0-ErrorAction\u00a0SilentlyContinue<\/p>\n<p>Write-Progress\u00a0-Activity\u00a0&#8220;Accepted Domains&#8221;\u00a0-status\u00a0&#8220;Collecting Accepted Domains info&#8221;<br \/>\n$AcceptedDomains\u00a0=\u00a0Get-AcceptedDomain\u00a0-ErrorAction\u00a0SilentlyContinue<\/p>\n<p>Write-Progress\u00a0-Activity\u00a0&#8220;OrgAdmins&#8221;\u00a0-status\u00a0&#8220;Collecting OrgAdmins info&#8221;<br \/>\n$OrgAdmins\u00a0=\u00a0Get-RoleGroupMember\u00a0&#8220;Organization Management&#8221;\u00a0-ErrorAction\u00a0SilentlyContinue<\/p>\n<p>#Applying Initial CSS For the HTML<br \/>\nWrite-Progress\u00a0-Activity\u00a0&#8220;ModernExchangeEnvironmentReport&#8221;\u00a0-status\u00a0&#8220;Applying CSS&#8221;<br \/>\n$head\u00a0=\u00a0@&#8221;<br \/>\n<Title>Volume Report<\/Title><br \/>\n<Style><br \/>\n.CSSTableGenerator {<br \/>\nmargin:0px;padding:0px;<br \/>\nwidth:100%;<br \/>\nbox-shadow: 10px 10px 5px #888888;<br \/>\nborder:1px solid #7aa3c1;<\/p>\n<p>-moz-border-radius-bottomleft:0px;<br \/>\n-webkit-border-bottom-left-radius:0px;<br \/>\nborder-bottom-left-radius:0px;<\/p>\n<p>-moz-border-radius-bottomright:0px;<br \/>\n-webkit-border-bottom-right-radius:0px;<br \/>\nborder-bottom-right-radius:0px;<\/p>\n<p>-moz-border-radius-topright:0px;<br \/>\n-webkit-border-top-right-radius:0px;<br \/>\nborder-top-right-radius:0px;<\/p>\n<p>-moz-border-radius-topleft:0px;<br \/>\n-webkit-border-top-left-radius:0px;<br \/>\nborder-top-left-radius:0px;<br \/>\n}.CSSTableGenerator table{<br \/>\nborder-collapse: collapse;<br \/>\nborder-spacing: 0;<br \/>\nwidth:100%;<br \/>\nheight:100%;<br \/>\nmargin:0px;padding:0px;<br \/>\n}.CSSTableGenerator tr:last-child td:last-child {<br \/>\n-moz-border-radius-bottomright:0px;<br \/>\n-webkit-border-bottom-right-radius:0px;<br \/>\nborder-bottom-right-radius:0px;<br \/>\n}<br \/>\n.CSSTableGenerator table tr:first-child td:first-child {<br \/>\n-moz-border-radius-topleft:0px;<br \/>\n-webkit-border-top-left-radius:0px;<br \/>\nborder-top-left-radius:0px;<br \/>\n}<br \/>\n.CSSTableGenerator table tr:first-child td:last-child {<br \/>\n-moz-border-radius-topright:0px;<br \/>\n-webkit-border-top-right-radius:0px;<br \/>\nborder-top-right-radius:0px;<br \/>\n}.CSSTableGenerator tr:last-child td:first-child{<br \/>\n-moz-border-radius-bottomleft:0px;<br \/>\n-webkit-border-bottom-left-radius:0px;<br \/>\nborder-bottom-left-radius:0px;<br \/>\n}.CSSTableGenerator tr:hover td{<\/p>\n<p>}<br \/>\n.CSSTableGenerator tr:nth-child(odd){ background-color:#ffffff; }<br \/>\n.CSSTableGenerator tr:nth-child(even){ background-color:#ffffff; }<br \/>\n.CSSTableGenerator td{<br \/>\nvertical-align:middle;<br \/>\nborder:1px solid #7aa3c1;<br \/>\nborder-width:0px 1px 1px 0px;<br \/>\ntext-align:center;<br \/>\npadding:8px;<br \/>\nfont-size:10px;<br \/>\nfont-family:Arial;<br \/>\nfont-weight:normal;<br \/>\ncolor:#000000;<br \/>\n}.CSSTableGenerator tr:last-child td{<br \/>\nborder-width:0px 1px 0px 0px;<br \/>\n}.CSSTableGenerator tr td:last-child{<br \/>\nborder-width:0px 0px 1px 0px;<br \/>\n}.CSSTableGenerator tr:last-child td:last-child{<br \/>\nborder-width:0px 0px 0px 0px;<br \/>\n}<br \/>\n.CSSTableGenerator tr:first-child td{<br \/>\nbackground:-o-linear-gradient(bottom, #0072c6 5%, #0072c6 100%);<br \/>\nbackground:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #0072c6), color-stop(1, #0072c6) );<br \/>\nbackground:-moz-linear-gradient( center top, #0072c6 5%, #0072c6 100% );<br \/>\nfilter:progid:DXImageTransform.Microsoft.gradient(startColorstr=&#8221;#0072c6&#8243;, endColorstr=&#8221;#0072c6&#8243;);<br \/>\nbackground: -o-linear-gradient(top,#0072c6,0072c6);<br \/>\nbackground-color:#0072c6;<br \/>\nborder:0px solid #7aa3c1;<br \/>\ntext-align:center;<br \/>\nborder-width:0px 0px 1px 1px;<br \/>\nfont-size:14px;<br \/>\nfont-family:Trebuchet MS;<br \/>\nfont-weight:bold;<br \/>\ncolor:#ffffff;<br \/>\n}<br \/>\n.CSSTableGenerator tr:first-child:hover td{<br \/>\nbackground:-o-linear-gradient(bottom, #0072c6 5%, #0072c6 100%);<br \/>\nbackground:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #0072c6), color-stop(1, #0072c6) );<br \/>\nbackground:-moz-linear-gradient( center top, #0072c6 5%, #0072c6 100% );<br \/>\nfilter:progid:DXImageTransform.Microsoft.gradient(startColorstr=&#8221;#0072c6&#8243;, endColorstr=&#8221;#0072c6&#8243;);<br \/>\nbackground: -o-linear-gradient(top,#0072c6,0072c6);<br \/>\nbackground-color:#0072c6;<br \/>\n}<br \/>\n.CSSTableGenerator tr:first-child td:first-child{<br \/>\nborder-width:0px 0px 1px 0px;<br \/>\n}<br \/>\n.CSSTableGenerator tr:first-child td:last-child{<br \/>\nborder-width:0px 0px 1px 1px;<br \/>\n}<br \/>\nh1 {<br \/>\nfont-size:14px;<br \/>\nfont-family:Trebuchet MS;<br \/>\nfont-weight:bold;<br \/>\nfont-color:#7aa3c1<br \/>\n}<br \/>\n<\/Style><br \/>\n&#8220;@<\/p>\n<p>#Create Tables in split so that users can remove or add tables easily.<br \/>\n$start\u00a0=\u00a0@&#8221;<br \/>\n<html><\/p>\n<div class=\"CSSTableGenerator\">\n&#8220;@<br \/>\nWrite-Progress\u00a0-Activity\u00a0&#8220;ModernExchangeEnvironmentReport&#8221;\u00a0-status\u00a0&#8220;Writing Enviroment Initial Info&#8221;<br \/>\n$Table1\u00a0=@&#8221;<br \/>\n<H1>Exchange Environment Report<\/h1>\n<table>\n<tr>\n<td>No.Exchange Servers<\/td>\n<td>No.Databases<\/td>\n<td>No.Mailboxes<\/td>\n<td>No.PublicFolder Mailboxes<\/td>\n<td>No.DistributionGroups<\/td>\n<td>No.DynamicGroups<\/td>\n<td>No.Contacts<\/td>\n<td>No.DAG<\/td>\n<td>No.Domains<\/td>\n<td>No.OrgAdmins<\/td>\n<td>Date<\/td>\n<\/tr>\n<tr>\n<td>$($ExchangeServers.count)<\/td>\n<td>$($Databases.count)<\/td>\n<td>$($mailboxes.count)<\/td>\n<td>$($PFmailboxes.count)<\/td>\n<td>$($DistributionGroups.count)<\/td>\n<td>$($DynamicGroups.count)<\/td>\n<td>$($MailContacts.count)<\/td>\n<td>$($DAG.count)<\/td>\n<td>$($AcceptedDomains.count)<\/td>\n<td>$($OrgAdmins.count)<\/td>\n<td>$($Date)<\/td>\n<\/tr>\n<\/table>\n<table>\n<tr>\n<td>Exchange Servers<\/td>\n<td>Roles<\/td>\n<td>Edition<\/td>\n<td>Site<\/td>\n<td>Version<\/td>\n<td>Operating System<\/td>\n<td>SendConnectors Used<\/td>\n<\/tr>\n<p>&#8220;@<\/p>\n<p>Write-Progress\u00a0-Activity\u00a0&#8220;ExchangeServers&#8221;\u00a0-status\u00a0&#8220;Writing ExchangeServers info&#8221;<br \/>\n$Table2\u00a0=<br \/>\nforeach\u00a0($server\u00a0in\u00a0($ExchangeServers))<br \/>\n{&#8220;<\/p>\n<tr>\n<td>$($server.name)<\/td>\n<td>$($server.serverrole)<\/td>\n<td>$($server.edition)<\/td>\n<td>$($server.site.name)<\/td>\n<td>$($server.AdmindisplayVersion -replace &#8220;version&#8221;,&#8221;)<\/td>\n<td>\n$($windows2012above = ((Get-WmiObject -ComputerName $server.name -class Win32_OperatingSystem -ErrorAction SilentlyContinue) | Where-Object{($_.Version -like &#8220;6.*&#8221;) -or ($_.version -like &#8220;10.*&#8221;) -and ($_.Version -notlike &#8220;6.1.*&#8221;) -and ($_.version -notlike &#8220;6.0.*&#8221;)}).version.count<br \/>\nif ($windows2012above -eq 1)<br \/>\n{(Get-CimInstance -ComputerName $server.name Win32_OperatingSystem).caption -replace &#8220;Microsoft Windows Server&#8221;,&#8221;})<\/td>\n<td>$(($SendConnectors | Where-Object{$_.SourceTransportServers -match &#8220;$($server.name)&#8221;}).identity.name)<\/td>\n<\/tr>\n<p>&#8220;}<\/p>\n<p>$table2close\u00a0=\u00a0@&#8221;<br \/>\n<\/table>\n<p>&#8220;@<\/p>\n<p>Write-Progress\u00a0-Activity\u00a0&#8220;Databases&#8221;\u00a0-status\u00a0&#8220;Writing Database info&#8221;<br \/>\n$Table3\u00a0=@&#8221;<\/p>\n<h1>Mailbox DB Stats<\/h1>\n<table>\n<tr>\n<td>Mailbox Databases<\/td>\n<td>Mounted<\/td>\n<td>ContentIndex<\/td>\n<td>DBSize<\/td>\n<td>WhiteSpace<\/td>\n<td>Mailboxes<\/td>\n<td>Master Group<\/td>\n<td>Database copies<\/td>\n<td>MbxRetention.Days<\/td>\n<td>ItemRetention.Days<\/td>\n<td>CircularLogging<\/td>\n<td>Provisioning Suspended<\/td>\n<td>Provisioning Disabled<\/td>\n<td>Last Full Backup<\/td>\n<\/tr>\n<p>&#8220;@<\/p>\n<p>$Table3data\u00a0=\u00a0foreach\u00a0($Database\u00a0in\u00a0$Databases)<br \/>\n{<br \/>\n$dbsize\u00a0= $($Database.databasesize\u00a0-replace\u00a0&#8220;\\(.*&#8221;,&#8221;)<\/p>\n<p>$dbWhitespace\u00a0= $($database.AvailableNewMailboxSpace\u00a0-replace\u00a0&#8220;\\(.*&#8221;,&#8221;)<\/p>\n<p>$Mountstatus\u00a0= $($Database.Mounted)<\/p>\n<p>if($Mountstatus\u00a0-eq\u00a0&#8220;True&#8221;)<br \/>\n{<br \/>\n$Mcolor\u00a0=\u00a0&#8220;#99FF66&#8221;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\n$Mcolor\u00a0=\u00a0&#8220;#FF5050&#8221;<br \/>\n}<\/p>\n<p>$ContentIndexStatus\u00a0= $((Get-MailboxDatabaseCopyStatus\u00a0&#8220;$($database.name)\\$($database.servername)&#8221;).contentindexstate)<br \/>\nif($ContentIndexStatus\u00a0-eq\u00a0&#8220;Healthy&#8221;)<br \/>\n{<br \/>\n$color\u00a0=\u00a0&#8220;#99FF66&#8221;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\n$color\u00a0=\u00a0&#8220;#FF5050&#8221;<br \/>\n}<\/p>\n<p>&#8220;<\/p>\n<tr>\n<td>$($Database.name)<\/td>\n<td bgcolor = $Mcolor>$($Database.Mountedonserver)<\/td>\n<td bgcolor = $color>$ContentIndexStatus<\/td>\n<td>$dbsize<\/td>\n<td bgcolor = $WSColor>$dbWhitespace<\/td>\n<td>$((get-mailbox -database $Database).count)<\/td>\n<td>$($Database.MasterServerOrAvailabilityGroup)<\/td>\n<td>$($Database.databasecopies.identity.name)<\/td>\n<td>$($Database.MailboxRetention.days)<\/td>\n<td>$($Database.DeletedItemRetention.days)<\/td>\n<td>$($Database.CircularLoggingEnabled -replace &#8220;False&#8221;,&#8221;No&#8221; -replace &#8220;True&#8221;,&#8221;Yes&#8221;)<\/td>\n<td>$($database.IsSuspendedFromProvisioning -replace &#8220;False&#8221;,&#8221;No&#8221; -replace &#8220;True&#8221;,&#8221;Yes&#8221;)<\/td>\n<td>$($database.IsExcludedFromProvisioning -replace &#8220;False&#8221;,&#8221;No&#8221; -replace &#8220;True&#8221;,&#8221;Yes&#8221;)<\/td>\n<td>$($database.lastfullbackup)<\/td>\n<\/tr>\n<p>&#8221;<br \/>\n}<\/p>\n<p>$table3close\u00a0=\u00a0@&#8221;<br \/>\n<\/table>\n<p>&#8220;@<\/p>\n<p>if($dags.count\u00a0-ge\u00a01)<br \/>\n{<br \/>\nWrite-Progress\u00a0-Activity\u00a0&#8220;Dag&#8221;\u00a0-status\u00a0&#8220;Writing DaG info&#8221;<br \/>\n$Table4\u00a0=@&#8221;<\/p>\n<h1>DAG statistics<\/h1>\n<table>\n<tr>\n<td>DAG Name <\/td>\n<td>Member Servers<\/td>\n<td>DAC Mode<\/td>\n<td>Witness server<\/td>\n<td>Witness Directory<\/td>\n<\/tr>\n<p>&#8220;@<\/p>\n<p>$Table4data\u00a0=\u00a0foreach\u00a0($dag\u00a0in\u00a0$dags)<br \/>\n{&#8220;<\/p>\n<tr>\n<td>$($DAG.name)<\/td>\n<td>$($dag.servers.name)<\/td>\n<td>$($dag.DatacenterActivationMode)<\/td>\n<td>$($dag.Witnessserver)<\/td>\n<td>$($dag.WitnessDirectory)<\/td>\n<\/tr>\n<p>&#8221;<br \/>\n}<\/p>\n<p>$table4close\u00a0=\u00a0@&#8221;<br \/>\n<\/table>\n<p>&#8220;@<\/p>\n<p>Write-Progress\u00a0-Activity\u00a0&#8220;Dag&#8221;\u00a0-status\u00a0&#8220;Writing DaG Replication info&#8221;<br \/>\n$Table5\u00a0=@&#8221;<\/p>\n<h1>Server Statistics<\/h1>\n<table>\n<tr>\n<td>Server<\/td>\n<td>Check<\/td>\n<td>Result<\/td>\n<td>Error<\/td>\n<\/tr>\n<p>&#8220;@<\/p>\n<p>Write-Progress\u00a0-Activity\u00a0&#8220;Dag&#8221;\u00a0-status\u00a0&#8220;Writing DaG info&#8221;<\/p>\n<p>$Table5data\u00a0=\u00a0foreach\u00a0($dag\u00a0in\u00a0$dags)<br \/>\n{<br \/>\nforeach\u00a0($member\u00a0in\u00a0$((Get-DatabaseAvailabilityGroup\u00a0$dag).servers.name))<br \/>\n{<br \/>\n$replstatus\u00a0=\u00a0Test-ReplicationHealth\u00a0$member<br \/>\nfor($i=0;$i\u00a0-lt\u00a0$replstatus.count;$i++)<br \/>\n{<br \/>\nif($replstatus.result[$i].value\u00a0-eq\u00a0&#8220;Passed&#8221;)<br \/>\n{<br \/>\n$Rcolor\u00a0=\u00a0&#8220;#99FF66&#8221;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\n$Rcolor\u00a0=\u00a0&#8220;#FF5050&#8221;<br \/>\n}<br \/>\n&#8220;<\/p>\n<tr>\n<td>$(($replstatus).Server[$i])<\/td>\n<td>$(($replstatus).Check[$i])<\/td>\n<td bgcolor = $Rcolor>$($replstatus.Result[$i].value)<\/td>\n<td>$(($replstatus).Error[$i])<\/td>\n<\/tr>\n<p>&#8221;<br \/>\n}<br \/>\n}<br \/>\n}<\/p>\n<p>$table5close\u00a0=\u00a0@&#8221;<br \/>\n<\/table>\n<p>&#8220;@<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nWrite-Progress\u00a0-Activity\u00a0&#8220;Dag&#8221;\u00a0-status\u00a0&#8220;Skipping DaG &#8211; No DAG Found&#8221;<br \/>\n}<\/p>\n<p>$MailqueueTb=\u00a0@&#8221;<\/p>\n<h1>Mail Queues<\/h1>\n<table>\n<tr>\n<td>Next Hop Domain<\/td>\n<td>Status<\/td>\n<td>Message Count<\/td>\n<td>Freespace (GB)<\/td>\n<\/tr>\n<p>&#8220;@<\/p>\n<p>Write-Progress\u00a0-Activity\u00a0&#8220;Mail Queues&#8221;\u00a0-status\u00a0&#8220;Perusing the Mail Queues&#8221;<\/p>\n<p>Foreach\u00a0($server\u00a0in\u00a0$ExchangeServers){<br \/>\n$MailQueues\u00a0+=\u00a0Get-Queue\u00a0-server\u00a0$server\u00a0|\u00a0Select-Object\u00a0NextHopDomain, Status, @{Label=&#8221;Message Count&#8221;;Expression={if\u00a0($_.MessageCount\u00a0-lt\u00a030){&#8220;#div_gre&#8221;+\u00a0$_.MessageCount}else{&#8220;#div_red&#8221;+\u00a0$_.MessageCount}}}, Identity<br \/>\n}<br \/>\n$MailQueues\u00a0=\u00a0$MailQueues|ConvertTo-Html\u00a0-Fragment<br \/>\n$file\u00a0=\u00a0&#8220;.\\MailQueues.txt&#8221;<br \/>\n$MailQueues\u00a0| SC\u00a0$file<br \/>\n(GC\u00a0$file|Select-Object\u00a0-Skip\u00a03)|SC\u00a0$file<br \/>\n$MailQueues\u00a0= GC\u00a0$file<br \/>\n$MailQueues\u00a0=\u00a0$MailQueues\u00a0-replace\u00a0&#8216;<\/p>\n<td>#div_red&#8217;,\u00a0&#8216;<\/p>\n<td bgcolor = red>&#8216;<br \/>\n$MailQueues\u00a0=\u00a0$MailQueues\u00a0-replace\u00a0&#8216;<\/p>\n<td>#div_gre&#8217;,\u00a0&#8216;<\/p>\n<td bgcolor = #99FF66>&#8216;<br \/>\nRemove-Item\u00a0$file<\/p>\n<p>$table6=\u00a0@&#8221;<\/p>\n<h1>Server Drive Space Statistics<\/h1>\n<table>\n<tr>\n<td>Server<\/td>\n<td>Volume<\/td>\n<td>Capacity (GB)<\/td>\n<td>Freespace (GB)<\/td>\n<td>Percent Free<\/td>\n<\/tr>\n<p>&#8220;@<\/p>\n<p>Write-Progress\u00a0-Activity\u00a0&#8220;Drive Space&#8221;\u00a0-status\u00a0&#8220;Writing Drive Space info&#8221;<br \/>\n$threshold=&#8217;90&#8217;<br \/>\nWrite-Verbose\u00a0-Message\u00a0&#8220;===================================`n= DISK SPACE CHECKS =`n= Checks the size of volumes, including =`n= mount points, and shows those with =`n= less than $threshold% free. =`n============================================&#8221;<br \/>\n$thresholdMsg\u00a0=\u00a0&#8220;<\/p>\n<div class='threshold'>Drive(s) listed below have less than $threshold% free space. Drives above this threshold will not be listed.<\/div>\n<p>&#8221;<br \/>\n$onlinelist\u00a0= @()<br \/>\n$offlinelist\u00a0= @()<br \/>\n$results\u00a0= @()<br \/>\nWrite-Verbose\u00a0-Message\u00a0&#8216;Performing ping test on servers &#8230;&#8217;<br \/>\n$exchangeservers|ForEach-Object\u00a0-Process\u00a0{<br \/>\nif(Test-Connection\u00a0-ComputerName\u00a0$_\u00a0-Quiet\u00a0-Count\u00a02)<br \/>\n{<br \/>\nWrite-Verbose\u00a0-Message\u00a0&#8220;`t$_ is up&#8221;<br \/>\n$onlinelist\u00a0+=\u00a0$_<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nWrite-Warning\u00a0-Message\u00a0&#8220;`t`t`t`t$_ is down&#8221;<br \/>\n$offlinelist\u00a0+=\u00a0$_<br \/>\n}<br \/>\n}<\/p>\n<p>if($offlinelist\u00a0-ne\u00a0$null)<br \/>\n{<br \/>\n$ofs\u00a0=\u00a0&#8216;,&#8217;<br \/>\n$offlineMsg\u00a0=\u00a0&#8220;<\/p>\n<div class='offline'>The following servers are offline: $offlinelist<\/div>\n<p>&#8221;<br \/>\n$ofs\u00a0=\u00a0&#8216; &#8216;<br \/>\n}<br \/>\nForEach($server\u00a0in\u00a0$onlinelist)<br \/>\n{<br \/>\nTry<br \/>\n{<br \/>\nWrite-Verbose\u00a0-Message\u00a0&#8220;Gathering drive info on $server&#8221;<br \/>\n$row\u00a0=\u00a0Get-WmiObject\u00a0-ComputerName\u00a0$server\u00a0-Class\u00a0Win32_Volume `<br \/>\n|<br \/>\nWhere-Object\u00a0-FilterScript\u00a0{<br \/>\n$_.DriveType\u00a0-eq\u00a0&#8216;3&#8217;<br \/>\n} `<br \/>\n|<br \/>\nWhere-Object\u00a0-FilterScript\u00a0{<br \/>\n$_.Capacity\u00a0-gt\u00a00<br \/>\n} `<br \/>\n|<br \/>\nWhere-Object\u00a0-FilterScript\u00a0{<br \/>\n($_.freespace\/$_.capacity)*100\u00a0-lt\u00a0$threshold<br \/>\n} `<br \/>\n|<br \/>\nSelect-Object\u00a0-Property\u00a0SystemName, Name, @{<br \/>\nn =\u00a0&#8216;Capacity (GB)&#8217;<br \/>\ne = {<br \/>\n&#8216;{0:n2}&#8217;\u00a0-f\u00a0($_.capacity\/1gb)<br \/>\n}<br \/>\n}, @{<br \/>\nn =\u00a0&#8216;FreeSpace (GB)&#8217;<br \/>\ne = {<br \/>\n&#8216;{0:n2}&#8217;\u00a0-f\u00a0($_.freeSpace\/1gb)<br \/>\n}<br \/>\n}, @{<br \/>\nn =\u00a0&#8216;PercentFree&#8217;<br \/>\ne = {<br \/>\nif(&#8216;{0:n2}&#8217;\u00a0-f\u00a0(($_.freespace\/$_.capacity)*100)\u00a0-lt\u00a010)<br \/>\n{<br \/>\n&#8220;#div_red&#8221;+'{0:n2}&#8217;\u00a0-f\u00a0($_.freespace\/$_.capacity*100)<br \/>\n}<br \/>\nelseif(&#8216;{0:n2}&#8217;\u00a0-f\u00a0(($_.freespace\/$_.capacity)*100)\u00a0-lt\u00a015)<br \/>\n{<br \/>\n&#8220;#div_ora&#8221;+'{0:n2}&#8217;\u00a0-f\u00a0($_.freespace\/$_.capacity*100)<br \/>\n}<br \/>\nelseif(&#8216;{0:n2}&#8217;\u00a0-f\u00a0(($_.freespace\/$_.capacity)*100)\u00a0-lt\u00a020)<br \/>\n{<br \/>\n&#8220;#div_yel&#8221;+'{0:n2}&#8217;\u00a0-f\u00a0(($_.freespace\/$_.capacity)*100)<br \/>\n}<br \/>\nelseif(&#8216;{0:n2}&#8217;\u00a0-f\u00a0($_.freespace\/$_.capacity*100)\u00a0-gt\u00a020)<br \/>\n{<br \/>\n&#8220;#div_gre&#8221;+'{0:n2}&#8217;\u00a0-f\u00a0(($_.freespace\/$_.capacity)*100)<br \/>\n}<br \/>\n}<br \/>\n}<br \/>\n}<br \/>\nCatch\u00a0[System.Exception]<br \/>\n{<br \/>\nWrite-Warning\u00a0-Message\u00a0$_.Exception.Message<br \/>\n}<br \/>\n$results\u00a0+=\u00a0$row<br \/>\n}<br \/>\n$results\u00a0=\u00a0$results|ConvertTo-Html\u00a0-Fragment<br \/>\n$file\u00a0=\u00a0&#8220;.\\results.txt&#8221;<br \/>\n$results\u00a0| SC\u00a0$file<br \/>\n(GC\u00a0$file|Select-Object\u00a0-Skip\u00a03)|SC\u00a0$file<br \/>\n$results\u00a0= GC\u00a0$file<br \/>\n$results\u00a0=\u00a0$results\u00a0-replace\u00a0&#8216;<\/p>\n<td>#div_yel&#8217;,\u00a0&#8216;<\/p>\n<td bgcolor = yellow>&#8216;<br \/>\n$results\u00a0=\u00a0$results\u00a0-replace\u00a0&#8216;<\/p>\n<td>#div_ora&#8217;,\u00a0&#8216;<\/p>\n<td bgcolor = orange>&#8216;<br \/>\n$results\u00a0=\u00a0$results\u00a0-replace\u00a0&#8216;<\/p>\n<td>#div_red&#8217;,\u00a0&#8216;<\/p>\n<td bgcolor = red>&#8216;<br \/>\n$results\u00a0=\u00a0$results\u00a0-replace\u00a0&#8216;<\/p>\n<td>#div_gre&#8217;,\u00a0&#8216;<\/p>\n<td bgcolor = #99FF66>&#8216;<br \/>\nRemove-Item\u00a0$file<\/p>\n<p>$table6close=@&#8221;<\/p>\n<p>&#8220;@<\/p>\n<p>Write-Progress\u00a0-Activity\u00a0&#8220;Log Sizes&#8221;\u00a0-status\u00a0&#8220;Writing Log Size info&#8221;<br \/>\n$table7=@&#8221;<\/p>\n<h1>Exchange Log Sizes<\/h1>\n<table>\n<tr>\n<td>Log Path<\/td>\n<td>Size MB<\/td>\n<\/tr>\n<p>&#8220;@<\/p>\n<p>$trupath\u00a0= @()<br \/>\n$databases\u00a0|\u00a0ForEach-ObJect{<br \/>\n$logpath\u00a0=\u00a0$_.LogFolderPath.ToString()<br \/>\n$logserver\u00a0=\u00a0$_.Servername.ToString()<br \/>\n$trupath\u00a0+=\u00a0$logpath\u00a0-replace\u00a0&#8220;C:\\\\&#8221;,\u00a0&#8220;\\\\$logserver\\c$\\&#8221;<br \/>\n}<\/p>\n<p>$table7data=ForEach($pat\u00a0in\u00a0$trupath){<br \/>\n$size\u00a0=\u00a0&#8220;{0:N2} MB&#8221;\u00a0-f\u00a0((GCI\u00a0$pat\u00a0-recurse\u00a0|Measure-Object\u00a0-Property\u00a0Length\u00a0-Sum\u00a0-ErrorAction\u00a0Stop).Sum \/ 1MB)<br \/>\n&#8220;<\/p>\n<tr>\n<td>$Pat<\/td>\n<td>$size<\/td>\n<\/tr>\n<p>&#8221;<br \/>\n}<\/p>\n<p>$table7close=@&#8221;<br \/>\n<\/table>\n<p>&#8220;@<\/p>\n<p>$complete\u00a0=\u00a0@&#8221;\n<\/p><\/div>\n<p><\/html><br \/>\n&#8220;@<\/p>\n<p>#Combining All Tables.<\/p>\n<p>$alltables\u00a0=\u00a0&#8220;$start $Table1 $Table2 $table2close $Table3 $Table3data $table3close $Table4 $Table4data $table4close $Table5 $Table5data $table5close $mailqueuetb $mailqueues $table6 $table6close $results $Table7 $Table7data $table7close &#8221;<\/p>\n<p>$Combine\u00a0=\u00a0ConvertTo-Html\u00a0-Head\u00a0$head\u00a0-Body\u00a0$alltables<\/p>\n<p>#Saving HTML File To the local C Drive &#8211; You can modify as per your wish.<br \/>\n$html\u00a0+=\u00a0$Combine<br \/>\n$html\u00a0>\u00a0$Attachment<\/p>\n<p>#open the HTML File Locally<br \/>\nIf($Openhtmllocally\u00a0-eq\u00a0&#8220;yes&#8221;)<br \/>\n{<br \/>\nInvoke-Item\u00a0&#8220;$Attachment&#8221;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nWrite-Progress\u00a0-Activity\u00a0&#8220;Open HTML&#8221;\u00a0-status\u00a0&#8220;Settings &#8211; Do not Open&#8221;<br \/>\n}<br \/>\n#Sending Email Message<\/p>\n<p>#Send-mailmessage\u00a0-to\u00a0$EmailTo\u00a0-from\u00a0$EmailFrom\u00a0-subject\u00a0$EmailSubject\u00a0-SmtpServer\u00a0$SmtpServer\u00a0-Body\u00a0&#8220;Please see attached&#8221;\u00a0-BodyAsHtml\u00a0-Attachments\u00a0$Attachment\u00a0-ErrorAction\u00a0SilentlyContinue<\/p>\n<p># House Keping<br \/>\nGCI .\\output\\ |\u00a0Where-Object\u00a0-FilterScript\u00a0{<br \/>\n$_.LastWriteTime\u00a0-lt\u00a0(Get-Date).AddDays(-6)}|Remove-Item<br \/>\n[\/CC]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have adapted the \u201cModern Exchange Environment Check\u201d from\u00a0Satheshwaran Manoharan\u00a0and for use on a Exchange&hellip;<\/p>\n","protected":false},"author":1,"featured_media":988,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4,19,11],"tags":[32,64],"class_list":["post-961","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-exchange","category-powershell","category-scripts","tag-exchange","tag-powershell"],"jetpack_featured_media_url":"https:\/\/ihni.uk\/wp-content\/uploads\/2020\/02\/Powershell.png","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ihni.uk\/index.php?rest_route=\/wp\/v2\/posts\/961","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ihni.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ihni.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ihni.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ihni.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=961"}],"version-history":[{"count":0,"href":"https:\/\/ihni.uk\/index.php?rest_route=\/wp\/v2\/posts\/961\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ihni.uk\/index.php?rest_route=\/wp\/v2\/media\/988"}],"wp:attachment":[{"href":"https:\/\/ihni.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=961"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ihni.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=961"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ihni.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=961"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}