From afa349e024fc64b07de943959b064a2d78c9861e Mon Sep 17 00:00:00 2001 From: David Paulson Date: Fri, 30 Aug 2024 14:20:33 -0500 Subject: [PATCH] Add msExchHomeServerName check for the critical mailboxes --- .../Domain/Test-ValidMailboxProperties.ps1 | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/Setup/SetupAssist/Checks/Domain/Test-ValidMailboxProperties.ps1 b/Setup/SetupAssist/Checks/Domain/Test-ValidMailboxProperties.ps1 index fb66ee7e3..08b05aa23 100644 --- a/Setup/SetupAssist/Checks/Domain/Test-ValidMailboxProperties.ps1 +++ b/Setup/SetupAssist/Checks/Domain/Test-ValidMailboxProperties.ps1 @@ -5,13 +5,14 @@ . $PSScriptRoot\..\..\..\..\Shared\ActiveDirectoryFunctions\Search-AllActiveDirectoryDomains.ps1 function Test-ValidMailboxProperties { - $testName = "Valid Home MDB" + $validHomeMdbTestName = "Valid Home MDB" # Need to make sure the property value homeMDB is not null and points to a valid database object. + $validHomeServerTestName = "Valid Home Server Name" # Need to make sure the property value msExchHomeServerName is not null. $arbitration = 0x800000 $discovery = 0x20000000 $publicFolder = 0x1000000000 $recipientTypes = $arbitration -bor $discovery -bor $publicFolder $filter = "(&(objectClass=user)(mailNickname=*)(msExchRecipientTypeDetails:1.2.840.113556.1.4.804:=$recipientTypes))" - $propsToLoad = @("distinguishedName", "homeMDB") + $propsToLoad = @("distinguishedName", "homeMDB", "msExchHomeServerName") $results = Search-AllActiveDirectoryDomains -Filter $filter -PropertiesToLoad $propsToLoad @@ -20,9 +21,10 @@ function Test-ValidMailboxProperties { foreach ($result in $results) { $dbName = $result.Properties["homeMDB"] + $mailboxDN = $result.Properties["distinguishedName"] $params = @{ - TestName = $testName - Details = ("Mailbox DN: $($result.Properties["distinguishedName"])`n" + + TestName = $validHomeMdbTestName + Details = ("Mailbox DN: $mailboxDN`n" + "Database DN: $dbName") ReferenceInfo = ("Run the following command in EMS.`n" + "If EMS is down, launch PowerShell and run `"Add-PSSnapin *Exchange*`"`n" + @@ -35,8 +37,27 @@ function Test-ValidMailboxProperties { } else { New-TestResult @params -Result "Failed" } + + $homeServer = $result.Properties["msExchHomeServerName"] + $params = @{ + TestName = $validHomeServerTestName + Details = ("Mailbox DN: $mailboxDN`nHome Server Name: $homeServer") + ReferenceInfo = ("Run the following command in PowerShell or EMS.`n" + + "Set-ADObject 'DN' -Add @{msExchHomeServerName='AnExchangeServer-ExchangeLegacyDN-Value'}") + } + + if ((-not([string]::IsNullOrEmpty($homeServer)))) { + New-TestResult @params -Result "Passed" + } else { + New-TestResult @params -Result "Failed" + } } } else { - New-TestResult -TestName $testName -Result "Failed" -Details "Failed to find any critical mailboxes" + $params = @{ + Result = "Failed" + Details = "Failed to find any critical mailboxes" + } + New-TestResult @params -TestName $validHomeMdbTestName + New-TestResult @params -TestName $validHomeServerTestName } }