Skip to content

Commit

Permalink
Merge pull request #2181 from microsoft/dpaul-SetupAssistDev
Browse files Browse the repository at this point in the history
Add msExchHomeServerName test to SetupAssist
  • Loading branch information
dpaulson45 authored Sep 10, 2024
2 parents b38113f + afa349e commit b374c4e
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 44 deletions.
42 changes: 0 additions & 42 deletions Setup/SetupAssist/Checks/Domain/Test-ValidHomeMdb.ps1

This file was deleted.

63 changes: 63 additions & 0 deletions Setup/SetupAssist/Checks/Domain/Test-ValidMailboxProperties.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

. $PSScriptRoot\..\New-TestResult.ps1
. $PSScriptRoot\..\..\..\..\Shared\ActiveDirectoryFunctions\Search-AllActiveDirectoryDomains.ps1

function Test-ValidMailboxProperties {
$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", "msExchHomeServerName")

$results = Search-AllActiveDirectoryDomains -Filter $filter -PropertiesToLoad $propsToLoad

if ($null -ne $results -and
$results.Count -gt 0) {

foreach ($result in $results) {
$dbName = $result.Properties["homeMDB"]
$mailboxDN = $result.Properties["distinguishedName"]
$params = @{
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" +
" Set-Mailbox 'DN' -Database 'DB_Name'")
}

if ((-not([string]::IsNullOrEmpty($dbName))) -and
([ADSI]::Exists("LDAP://$dbName"))) {
New-TestResult @params -Result "Passed"
} 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 {
$params = @{
Result = "Failed"
Details = "Failed to find any critical mailboxes"
}
New-TestResult @params -TestName $validHomeMdbTestName
New-TestResult @params -TestName $validHomeServerTestName
}
}
4 changes: 2 additions & 2 deletions Setup/SetupAssist/SetupAssist.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ param(
. $PSScriptRoot\Checks\Domain\Test-DomainMultiActiveSyncVirtualDirectories.ps1
. $PSScriptRoot\Checks\Domain\Test-ExchangeADSetupLevel.ps1
. $PSScriptRoot\Checks\Domain\Test-DomainOtherWellKnownObjects.ps1
. $PSScriptRoot\Checks\Domain\Test-ValidHomeMdb.ps1
. $PSScriptRoot\Checks\Domain\Test-ValidMailboxProperties.ps1
. $PSScriptRoot\Checks\LocalServer\Test-ExecutionPolicy.ps1
. $PSScriptRoot\Checks\LocalServer\Test-ExchangeServices.ps1
. $PSScriptRoot\Checks\LocalServer\Test-InstallWatermark.ps1
Expand Down Expand Up @@ -56,7 +56,7 @@ function RunAllTests {
"Test-PrerequisiteInstalled",
"Test-DomainOtherWellKnownObjects",
"Test-PendingReboot",
"Test-ValidHomeMDB",
"Test-ValidMailboxProperties",
"Test-VirtualDirectoryConfiguration")

foreach ($test in $tests) {
Expand Down

0 comments on commit b374c4e

Please sign in to comment.