Skip to content

Commit

Permalink
Merge pull request #2188 from microsoft/dpaul-HcMonitoringOverride
Browse files Browse the repository at this point in the history
Add Monitoring Override Check and Analysis
  • Loading branch information
dpaulson45 authored Sep 17, 2024
2 parents 5246932 + 987fcde commit 1c4af31
Show file tree
Hide file tree
Showing 12 changed files with 230 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,33 @@ function Invoke-AnalyzerExchangeInformation {
}
}

$monitoringOverrides = New-Object System.Collections.Generic.List[object]
foreach ($monitoringOverride in $HealthServerObject.OrganizationInformation.GetGlobalMonitoringOverride.SimpleView) {
$monitoringOverrides.Add($monitoringOverride)
}
foreach ($monitoringOverride in $exchangeInformation.GetServerMonitoringOverride.SimpleView) {
$monitoringOverrides.Add($monitoringOverride)
}

$monitoringOverridesDetected = $monitoringOverrides.Count -gt 0
$params = $baseParams + @{
Name = "Monitoring Overrides Detected"
Details = $monitoringOverridesDetected
}

Add-AnalyzedResultInformation @params

if ($monitoringOverridesDetected) {
$params = $baseParams + @{
OutColumns = ([PSCustomObject]@{
DisplayObject = $monitoringOverrides
IndentSpaces = 12
})
HtmlName = "Monitoring Overrides"
}
Add-AnalyzedResultInformation @params
}

if ($null -ne $exchangeInformation.EdgeTransportResourceThrottling) {
try {
# SystemMemory does not block mail flow.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
. $PSScriptRoot\..\..\..\..\Shared\Get-ExchangeSettingOverride.ps1
. $PSScriptRoot\..\..\..\..\Shared\Get-ExSetupFileVersionInfo.ps1
. $PSScriptRoot\..\..\..\..\Shared\Get-FileContentInformation.ps1
. $PSScriptRoot\..\..\..\..\Shared\Get-MonitoringOverride.ps1
. $PSScriptRoot\IISInformation\Get-ExchangeAppPoolsInformation.ps1
. $PSScriptRoot\IISInformation\Get-ExchangeServerIISSettings.ps1
. $PSScriptRoot\Get-ExchangeAES256CBCDetails.ps1
Expand Down Expand Up @@ -211,6 +212,8 @@ function Get-ExchangeInformation {
}
$computerMembership = Invoke-ScriptBlockHandler @params
}

[array]$serverMonitoringOverride = Get-MonitoringOverride -Server $Server
} end {

Write-Verbose "Exiting: Get-ExchangeInformation"
Expand All @@ -236,6 +239,7 @@ function Get-ExchangeInformation {
AES256CBCInformation = $aes256CbcDetails
FileContentInformation = $fileContentInformation
ComputerMembership = $computerMembership
GetServerMonitoringOverride = $serverMonitoringOverride
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
. $PSScriptRoot\Get-SecurityCve-2021-34470.ps1
. $PSScriptRoot\Get-SecurityCve-2022-21978.ps1
. $PSScriptRoot\..\..\..\..\Shared\ActiveDirectoryFunctions\Get-ExchangeADSplitPermissionsEnabled.ps1
. $PSScriptRoot\..\..\..\..\Shared\Get-MonitoringOverride.ps1
. $PSScriptRoot\..\..\..\..\Shared\ErrorMonitorFunctions.ps1
. $PSScriptRoot\..\..\..\..\Shared\Invoke-CatchActionErrorLoop.ps1
function Get-OrganizationInformation {
Expand Down Expand Up @@ -139,6 +140,8 @@ function Get-OrganizationInformation {
$getSettingOverride = "Unknown"
Invoke-CatchActions
}

[array]$globalMonitoringOverride = Get-MonitoringOverride
}
} end {
return [PSCustomObject]@{
Expand All @@ -156,6 +159,7 @@ function Get-OrganizationInformation {
GetSettingOverride = $getSettingOverride
GetDynamicDgPublicFolderMailboxes = $getDdgPublicFolders
GetIrmConfiguration = $getIrmConfiguration
GetGlobalMonitoringOverride = $globalMonitoringOverride
}
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04">
<Obj RefId="0">
<TN RefId="0">
<T>Deserialized.Microsoft.Exchange.Monitoring.ActiveMonitoring.MonitoringOverrideObject</T>
<T>Deserialized.Microsoft.Exchange.Data.ConfigurableObject</T>
<T>Deserialized.System.Object</T>
</TN>
<ToString>Microsoft.Exchange.Monitoring.ActiveMonitoring.MonitoringOverrideObject</ToString>
<Props>
<S N="ItemType">Responder</S>
<S N="PropertyName">Enabled</S>
<S N="PropertyValue">0</S>
<S N="HealthSetName">AD</S>
<S N="MonitoringItemName">ActiveDirectoryConnectivityConfigDCServerReboot</S>
<S N="TargetResource"></S>
<S N="ExpirationTime">2024-09-29 17:40:49Z</S>
<S N="ApplyVersion"></S>
<S N="CreatedBy">Solo.com/Users/Han</S>
<S N="CreatedTime">2024-09-09 17:40:49Z</S>
<S N="Identity">AD\ActiveDirectoryConnectivityConfigDCServerReboot</S>
<B N="IsValid">true</B>
<S N="ObjectState">New</S>
</Props>
<MS>
<BA N="SerializationData">AAEAAAD/////AQAAAAAAAAAMAgAAAGFNaWNyb3NvZnQuRXhjaGFuZ2UuTWFuYWdlbWVudCwgVmVyc2lvbj0xNS4wLjAuMCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj0zMWJmMzg1NmFkMzY0ZTM1DAMAAABbTWljcm9zb2Z0LkV4Y2hhbmdlLkRhdGEsIFZlcnNpb249MTUuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49MzFiZjM4NTZhZDM2NGUzNQUBAAAAR01pY3Jvc29mdC5FeGNoYW5nZS5Nb25pdG9yaW5nLkFjdGl2ZU1vbml0b3JpbmcuTW9uaXRvcmluZ092ZXJyaWRlT2JqZWN0BAAAAAtwcm9wZXJ0eUJhZx5Db25maWd1cmFibGVPYmplY3QrcHJvcGVydHlCYWcsQ29uZmlndXJhYmxlT2JqZWN0K3NlcmlhbGl6ZXJBc3NlbWJseVZlcnNpb24mQ29uZmlndXJhYmxlT2JqZWN0K2luc3RhbnRpYXRpb25FcnJvcnMEBAMDMU1pY3Jvc29mdC5FeGNoYW5nZS5EYXRhLlNpbXBsZVByb3ZpZGVyUHJvcGVydHlCYWcDAAAAMU1pY3Jvc29mdC5FeGNoYW5nZS5EYXRhLlNpbXBsZVByb3ZpZGVyUHJvcGVydHlCYWcDAAAADlN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HJvcGVydHlCYWcrVmFsdWVQYWlyAgAAAANLZXkFVmFsdWUEAjhNaWNyb3NvZnQuRXhjaGFuZ2UuRGF0YS5TaW1wbGVQcm92aWRlclByb3BlcnR5RGVmaW5pdGlvbgMAAAADAAAACQkAAAAJCgAAAAH1////+P///wkMAAAACQ0AAAAB8v////j///8JDwAAAAkQAAAAAe/////4////CRIAAAAGEwAAAAlSZXNwb25kZXIB7P////j///8JFQAAAAYWAAAAB0VuYWJsZWQB6f////j///8JGAAAAAYZAAAAATAB5v////j///8JGwAAAAYcAAAAAkFEAeP////4////CR4AAAAGHwAAAC9BY3RpdmVEaXJlY3RvcnlDb25uZWN0aXZpdHlDb25maWdEQ1NlcnZlclJlYm9vdAHg////+P///wkhAAAABiIAAAAUMjAyNC0wOS0yOSAxNzo0MDo0OVoB3f////j///8JJAAAAAYlAAAAElNvbG8uY29tL1VzZXJzL0hhbgHa////+P///wknAAAABigAAAAUMjAyNC0wOS0wOSAxNzo0MDo0OVoHBwAAAAABAAAACwAAAAQtTWljcm9zb2Z0LkV4Y2hhbmdlLkRhdGEuUHJvcGVydHlCYWcrVmFsdWVQYWlyAwAAAAHX////+P///wkPAAAACgHV////+P///wkSAAAACgHT////+P///wkVAAAACgHR////+P///wkYAAAACgHP////+P///wkbAAAACgHN////+P///wkeAAAACgHL////+P///wk2AAAACgHJ////+P///wkhAAAACgHH////+P///wk6AAAACgHF////+P///wkkAAAACgHD////+P///wknAAAACgUJAAAAOE1pY3Jvc29mdC5FeGNoYW5nZS5EYXRhLlNpbXBsZVByb3ZpZGVyUHJvcGVydHlEZWZpbml0aW9uBQAAAAVmbGFncxdQcm9wZXJ0eURlZmluaXRpb24rbmFtZRdQcm9wZXJ0eURlZmluaXRpb24rdHlwZRtQcm9wZXJ0eURlZmluaXRpb24rdHlwZU5hbWU5UHJvcGVydHlEZWZpbml0aW9uK3JlcXVpcmVkUHJvcGVydHlEZWZpbml0aW9uc1doZW5SZWFkaW5nAAEDAQMIH1N5c3Rl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xpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkKAToAAAAJAAAAAAAAAAZlAAAADEFwcGx5VmVyc2lvbglLAAAABmcAAABaU3lzdGVtLlN0cmluZywgbXNjb3JsaWIsIFZlcnNpb249NC4wLjAuMCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5CgRAAAAAH1N5c3RlbS5Vbml0eVNlcmlhbGl6YXRpb25Ib2xkZXIDAAAABERhdGEJVW5pdHlUeXBlDEFzc2VtYmx5TmFtZQEAAQgGaAAAACNNaWNyb3NvZnQuRXhjaGFuZ2UuRGF0YS5PYmplY3RTdGF0ZQQAAAAGaQAAAFtNaWNyb3NvZnQuRXhjaGFuZ2UuRGF0YSwgVmVyc2lvbj0xNS4wLjAuMCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj0zMWJmMzg1NmFkMzY0ZTM1AUMAAABAAAAABmoAAAAtTWljcm9zb2Z0LkV4Y2hhbmdlLkRhdGEuRXhjaGFuZ2VPYmplY3RWZXJzaW9uBAAAAAlpAAAAAUcAAABAAAAABmwAAAAgTWljcm9zb2Z0LkV4Y2hhbmdlLkRhdGEuT2JqZWN0SWQEAAAACWkAAAABSwAAAEAAAAAGbgAAAA1TeXN0ZW0uU3RyaW5nBAAAAAZvAAAAS21zY29ybGliLCBWZXJzaW9uPTQuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49Yjc3YTVjNTYxOTM0ZTA4OQs=</BA>
<S N="PSComputerName">solo-e19a.solo.com</S>
<G N="RunspaceId">6f717724-bc29-4a09-a19f-5512f339b875</G>
<B N="PSShowComputerName">false</B>
</MS>
</Obj>
</Objs>
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Describe "Testing Health Checker by Mock Data Imports - Exchange 2013" {
TestObjectMatch "Internet Web Proxy" "Not Set"
TestObjectMatch "Extended Protection Enabled (Any VDir)" $false
TestObjectMatch "Setting Overrides Detected" $false
$Script:ActiveGrouping.Count | Should -Be 17
$Script:ActiveGrouping.Count | Should -Be 18
}

It "Display Results - Organization Information" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Describe "Testing Health Checker by Mock Data Imports - Exchange 2016" {
TestObjectMatch "Extended Protection Enabled (Any VDir)" $false
TestObjectMatch "Setting Overrides Detected" $false
TestObjectMatch "Exchange Server Membership" "Passed"
$Script:ActiveGrouping.Count | Should -Be 15
$Script:ActiveGrouping.Count | Should -Be 16
}

It "Display Results - Organization Information" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ Describe "Testing Health Checker by Mock Data Imports" {
TestObjectMatch "Internet Web Proxy" "Not Set"
TestObjectMatch "Extended Protection Enabled (Any VDir)" $false
TestObjectMatch "Setting Overrides Detected" $false
TestObjectMatch "Monitoring Overrides Detected" $false
TestObjectMatch "Out of Date" $true -WriteType "Red"
TestObjectMatch "Exchange Server Membership" "Passed"
$Script:ActiveGrouping.Count | Should -Be 15
$Script:ActiveGrouping.Count | Should -Be 16
}

It "Display Results - Organization Information" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ Describe "Testing Health Checker by Mock Data Imports" {
Mock Get-LocalGroupMember { return Import-Clixml "$Script:MockDataCollectionRoot\Exchange\GetLocalGroupMember2.xml" }
Mock Get-WindowsFeature { return Import-Clixml "$Script:MockDataCollectionRoot\OS\GetWindowsFeature1.xml" }
Mock Get-SmbServerConfiguration { return Import-Clixml "$Script:MockDataCollectionRoot\OS\GetSmbServerConfiguration1.xml" }
Mock Get-GlobalMonitoringOverride { return Import-Clixml "$Script:MockDataCollectionRoot\Exchange\GetGlobalMonitoringOverride.xml" }
Mock Get-ServerMonitoringOverride { return Import-Clixml "$Script:MockDataCollectionRoot\Exchange\GetServerMonitoringOverride.xml" }
Mock Get-WinEvent -ParameterFilter { $LogName -eq "Application" -and $Oldest -eq $true -and $MaxEvents -eq 1 } -MockWith {
$r = Import-Clixml "$Script:MockDataCollectionRoot\OS\GetWinEventOldestApplication.xml"
$r.TimeCreated = ((Get-Date).AddDays(-1))
Expand Down Expand Up @@ -121,6 +123,7 @@ Describe "Testing Health Checker by Mock Data Imports" {
TestObjectMatch "Exchange Server Membership" "Failed" -WriteType "Red"
TestObjectMatch "Exchange Trusted Subsystem - Local System Membership" "Exchange Trusted Subsystem - Local System Membership" -WriteType "Red"
TestObjectMatch "Exchange Trusted Subsystem - AD Group Membership" "Exchange Trusted Subsystem - AD Group Membership" -WriteType "Red"
TestObjectMatch "Monitoring Overrides Detected" $true
$hotfixInstalled = GetObject "Exchange IU"
$hotfixInstalled.Count | Should -Be 2
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ Describe "Testing Health Checker by Mock Data Imports" {
Mock Get-OutlookAnywhere { return $null }
Mock Get-PowerShellVirtualDirectory { return $null }
Mock Get-WindowsFeature { return Import-Clixml "$Script:MockDataCollectionRoot\OS\GetWindowsFeature.xml" }
Mock Get-GlobalMonitoringOverride { return $null }
Mock Get-ServerMonitoringOverride { return $null }

$Error.Clear()
Get-OrganizationInformation -EdgeServer $false | Out-Null
Expand Down Expand Up @@ -106,6 +108,8 @@ Describe "Testing Health Checker by Mock Data Imports" {
Assert-MockCalled Get-OutlookAnywhere -Exactly 1
Assert-MockCalled Get-PowerShellVirtualDirectory -Exactly 1
Assert-MockCalled Get-WindowsFeature -Exactly 1
Assert-MockCalled Get-GlobalMonitoringOverride -Exactly 1
Assert-MockCalled Get-ServerMonitoringOverride -Exactly 1
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -379,3 +379,11 @@ function Get-ExchangeWebSitesFromAd {
function Get-WindowsFeature {
return Import-Clixml "$Script:MockDataCollectionRoot\OS\GetWindowsFeature.xml"
}

function Get-GlobalMonitoringOverride {
return $null
}

function Get-ServerMonitoringOverride {
return $null
}
64 changes: 64 additions & 0 deletions Shared/Get-MonitoringOverride.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

function Get-MonitoringOverride {
[CmdletBinding()]
[OutputType([System.Collections.Generic.List[object]])]
param(
# If Server is provided, then we are doing Get-ServerMonitoringOverride. Otherwise, we are doing Get-GlobalMonitoringOverride.
[Parameter(Mandatory = $false)]
[string]$Server,

[Parameter(Mandatory = $false)]
[ScriptBlock]$CatchActionFunction
)
process {
try {
$monitoringOverrides = New-Object System.Collections.Generic.List[object]
$monitoringOverridesSimple = New-Object System.Collections.Generic.List[object]
$globalMonitoringOverride = [string]::IsNullOrEmpty($Server)
if ($globalMonitoringOverride) {
$monitoringOverride = Get-GlobalMonitoringOverride -ErrorAction Stop
} else {
$monitoringOverride = Get-ServerMonitoringOverride -Server $Server -ErrorAction Stop
}

foreach ($override in $monitoringOverride) {
$monitoringOverrides.Add([PSCustomObject]@{
ItemType = $override.ItemType
PropertyName = $override.PropertyName
PropertyValue = $override.PropertyValue
HealthSetName = $override.MonitoringItemName
TargetResource = $override.TargetResource
ExpirationTime = $override.ExpirationTime
ApplyVersion = $override.ApplyVersion
CreatedBy = $override.CreatedBy
CreatedTime = $override.CreatedTime
Identity = $override.Identity
IsValid = $override.IsValid
})
$monitoringOverridesSimple.Add([PSCustomObject]@{
Identity = $override.Identity
ItemType = $override.ItemType
PropertyName = $override.PropertyName
PropertyValue = $override.PropertyValue
ApplyVersion = $override.ApplyVersion
IsValid = $override.IsValid
IsGlobal = $globalMonitoringOverride
ExpirationTime = $override.ExpirationTime
})
}
return [PSCustomObject]@{
MonitoringOverrides = $monitoringOverrides
SimpleView = $monitoringOverridesSimple
}
} catch {

Write-Verbose "Failed to get the monitoring override. Inner Exception $_"

if ($null -ne $CatchActionFunction) {
& $CatchActionFunction
}
}
}
}

0 comments on commit 1c4af31

Please sign in to comment.