Skip to content

Commit

Permalink
Add msExchHomeServerName check for the critical mailboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
dpaulson45 committed Sep 10, 2024
1 parent 42594dd commit afa349e
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions Setup/SetupAssist/Checks/Domain/Test-ValidMailboxProperties.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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" +
Expand All @@ -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
}
}

0 comments on commit afa349e

Please sign in to comment.