Skip to content

Commit

Permalink
Merge pull request #1842 from microsoft/dpaul-HcDdgPf
Browse files Browse the repository at this point in the history
Health Checker detects multiple dynamic distribution groups system objects for public folder mailboxes
  • Loading branch information
dpaulson45 authored Oct 4, 2023
2 parents 438ba8a + aac3713 commit f92f47a
Show file tree
Hide file tree
Showing 11 changed files with 2,470 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,33 @@ function Invoke-AnalyzerOrganizationInformation {
}
Add-AnalyzedResultInformation @params
}

if ($null -ne $organizationInformation.GetDynamicDgPublicFolderMailboxes -and
$organizationInformation.GetDynamicDgPublicFolderMailboxes.Count -ne 0) {
$displayWriteType = "Green"

if ($organizationInformation.GetDynamicDgPublicFolderMailboxes.Count -gt 1) {
$displayWriteType = "Red"
}

$params = $baseParams + @{
Name = "Dynamic Distribution Group Public Folder Mailboxes Count"
Details = $organizationInformation.GetDynamicDgPublicFolderMailboxes.Count
DisplayWriteType = $displayWriteType
}

Add-AnalyzedResultInformation @params

if ($displayWriteType -ne "Green") {
$params = $baseParams + @{
Details = "More Information: https://aka.ms/HC-DynamicDgPublicFolderMailboxes"
DisplayCustomTabNumber = 2
DisplayWriteType = "Yellow"
}

Add-AnalyzedResultInformation @params
}
} else {
Write-Verbose "No Dynamic Distribution Group Public Folder Mailboxes found to review."
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ function Get-OrganizationInformation {
$wellKnownSecurityGroups = Get-ExchangeWellKnownSecurityGroups
$isSplitADPermissions = Get-ExchangeADSplitPermissionsEnabled -CatchActionFunction ${Function:Invoke-CatchActions}

try {
$getDdgPublicFolders = @(Get-DynamicDistributionGroup "PublicFolderMailboxes*" -IncludeSystemObjects -ErrorAction "Stop")
} catch {
Write-Verbose "Failed to get the dynamic distribution group for public folder mailboxes."
Invoke-CatchActions
}

try {
$rootDSE = [ADSI]("LDAP://$([System.DirectoryServices.ActiveDirectory.Domain]::GetComputerDomain().Name)/RootDSE")
$directorySearcher = New-Object System.DirectoryServices.DirectorySearcher
Expand Down Expand Up @@ -123,18 +130,19 @@ function Get-OrganizationInformation {
}
} end {
return [PSCustomObject]@{
GetOrganizationConfig = $organizationConfig
DomainsAclPermissions = $domainsAclPermissions
WellKnownSecurityGroups = $wellKnownSecurityGroups
AdSchemaInformation = $adSchemaInformation
GetHybridConfiguration = $getHybridConfiguration
EnableDownloadDomains = $enableDownloadDomains
GetAcceptedDomain = $getAcceptedDomain
MapiHttpEnabled = $mapiHttpEnabled
SecurityResults = $securityResults
IsSplitADPermissions = $isSplitADPermissions
ADSiteCount = $adSiteCount
GetSettingOverride = $getSettingOverride
GetOrganizationConfig = $organizationConfig
DomainsAclPermissions = $domainsAclPermissions
WellKnownSecurityGroups = $wellKnownSecurityGroups
AdSchemaInformation = $adSchemaInformation
GetHybridConfiguration = $getHybridConfiguration
EnableDownloadDomains = $enableDownloadDomains
GetAcceptedDomain = $getAcceptedDomain
MapiHttpEnabled = $mapiHttpEnabled
SecurityResults = $securityResults
IsSplitADPermissions = $isSplitADPermissions
ADSiteCount = $adSiteCount
GetSettingOverride = $getSettingOverride
GetDynamicDgPublicFolderMailboxes = $getDdgPublicFolders
}
}
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ Describe "Testing Health Checker by Mock Data Imports - Exchange 2013" {
TestObjectMatch "MAPI/HTTP Enabled" "True"
TestObjectMatch "Enable Download Domains" "Unknown"
TestObjectMatch "AD Split Permissions" "False"
TestObjectMatch "Dynamic Distribution Group Public Folder Mailboxes Count" 1 -WriteType "Green"

$Script:ActiveGrouping.Count | Should -Be 5
$Script:ActiveGrouping.Count | Should -Be 6
}

It "Display Results - Operating System Information" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ Describe "Testing Health Checker by Mock Data Imports - Exchange 2016" {
TestObjectMatch "MAPI/HTTP Enabled" "True"
TestObjectMatch "Enable Download Domains" "False"
TestObjectMatch "AD Split Permissions" "False"
TestObjectMatch "Dynamic Distribution Group Public Folder Mailboxes Count" 1 -WriteType "Green"

$Script:ActiveGrouping.Count | Should -Be 4
$Script:ActiveGrouping.Count | Should -Be 5
}

It "Display Results - Operating System Information" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ Describe "Testing Health Checker by Mock Data Imports" {
TestObjectMatch "MAPI/HTTP Enabled" "True"
TestObjectMatch "Enable Download Domains" "False"
TestObjectMatch "AD Split Permissions" "False"
TestObjectMatch "Dynamic Distribution Group Public Folder Mailboxes Count" 1 -WriteType "Green"

$Script:ActiveGrouping.Count | Should -Be 4
$Script:ActiveGrouping.Count | Should -Be 5
}

It "Display Results - Operating System Information" {
Expand Down Expand Up @@ -165,10 +166,16 @@ Describe "Testing Health Checker by Mock Data Imports" {
Mock Get-WebSite -ParameterFilter { $Name -eq "Default Web Site" } -MockWith { return Import-Clixml "$Script:MockDataCollectionRoot\Exchange\IIS\GetWebSite_DefaultWebSite1.xml" }
Mock Get-WebConfigFile -ParameterFilter { $PSPath -eq "IIS:\Sites\Default Web Site" } -MockWith { return [PSCustomObject]@{ FullName = "$Script:MockDataCollectionRoot\Exchange\IIS\DefaultWebSite_web2.config" } }
Mock Invoke-ScriptBlockHandler -ParameterFilter { $ScriptBlockDescription -eq "Getting applicationHost.config" } -MockWith { return Get-Content "$Script:MockDataCollectionRoot\Exchange\IIS\applicationHost2.config" -Raw }
Mock Get-DynamicDistributionGroup { return Import-Clixml "$Script:MockDataCollectionRoot\Exchange\GetDynamicDistributionGroupPfMailboxes1.xml" }

SetDefaultRunOfHealthChecker "Debug_Physical_Results.xml"
}

It "Dynamic Public Folder Mailboxes" {
SetActiveDisplayGrouping "Organization Information"
TestObjectMatch "Dynamic Distribution Group Public Folder Mailboxes Count" 2 -WriteType "Red"
}

It "Extended Protection Enabled" {
SetActiveDisplayGrouping "Exchange Information"
TestObjectMatch "Version" "Exchange 2019 CU12 Feb23SU"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Describe "Testing Health Checker by Mock Data Imports" {
Mock Get-AcceptedDomain { return Import-Clixml "$Script:MockDataCollectionRoot\Exchange\GetAcceptedDomain.xml" }
Mock Get-ReceiveConnector { return Import-Clixml "$Script:MockDataCollectionRoot\Exchange\GetReceiveConnector.xml" }
Mock Get-SendConnector { return Import-Clixml "$Script:MockDataCollectionRoot\Exchange\GetSendConnector.xml" }
Mock Get-DynamicDistributionGroup { return Import-Clixml "$Script:MockDataCollectionRoot\Exchange\GetDynamicDistributionGroupPfMailboxes.xml" }

$Error.Clear()
Get-OrganizationInformation -EdgeServer $false | Out-Null
Expand Down Expand Up @@ -90,6 +91,7 @@ Describe "Testing Health Checker by Mock Data Imports" {
Assert-MockCalled Get-IISModules -Exactly 1
Assert-MockCalled Get-ExchangeDiagnosticInfo -Exactly 1
Assert-MockCalled Get-ExchangeADSplitPermissionsEnabled -Exactly 1
Assert-MockCalled Get-DynamicDistributionGroup -Exactly 1
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ function Get-OrganizationConfig {
return Import-Clixml "$Script:MockDataCollectionRoot\Exchange\GetOrganizationConfig.xml"
}

function Get-DynamicDistributionGroup {
return Import-Clixml "$Script:MockDataCollectionRoot\Exchange\GetDynamicDistributionGroupPfMailboxes.xml"
}

function Get-HybridConfiguration { return $null }

# Needs to be a function as PS core doesn't have -ComputerName parameter
Expand Down

0 comments on commit f92f47a

Please sign in to comment.