From 78c895c75d5d421f40c64a2a34d5f31c4199e9d0 Mon Sep 17 00:00:00 2001 From: David Paulson Date: Wed, 18 Oct 2023 10:06:18 -0500 Subject: [PATCH] Address not thrown Get-DynamicDistributionGroup error --- .../OrganizationInformation/Get-OrganizationInformation.ps1 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Diagnostics/HealthChecker/DataCollection/OrganizationInformation/Get-OrganizationInformation.ps1 b/Diagnostics/HealthChecker/DataCollection/OrganizationInformation/Get-OrganizationInformation.ps1 index 91d0f37789..d987c9eb6c 100644 --- a/Diagnostics/HealthChecker/DataCollection/OrganizationInformation/Get-OrganizationInformation.ps1 +++ b/Diagnostics/HealthChecker/DataCollection/OrganizationInformation/Get-OrganizationInformation.ps1 @@ -7,6 +7,8 @@ . $PSScriptRoot\Get-SecurityCve-2021-34470.ps1 . $PSScriptRoot\Get-SecurityCve-2022-21978.ps1 . $PSScriptRoot\..\..\..\..\Shared\ActiveDirectoryFunctions\Get-ExchangeADSplitPermissionsEnabled.ps1 +. $PSScriptRoot\..\..\..\..\Shared\ErrorMonitorFunctions.ps1 +. $PSScriptRoot\..\..\..\..\Shared\Invoke-CatchActionErrorLoop.ps1 function Get-OrganizationInformation { [CmdletBinding()] param( @@ -74,7 +76,10 @@ function Get-OrganizationInformation { } try { + # It was reported that this isn't getting thrown to the catch action when failing. As a quick fix, handling this by looping over errors. + $currentErrors = $Error.Count $getDdgPublicFolders = @(Get-DynamicDistributionGroup "PublicFolderMailboxes*" -IncludeSystemObjects -ErrorAction "Stop") + Invoke-CatchActionErrorLoop $currentErrors ${Function:Invoke-CatchActions} } catch { Write-Verbose "Failed to get the dynamic distribution group for public folder mailboxes." Invoke-CatchActions