Skip to content

Commit

Permalink
Merge pull request #2051 from microsoft/main
Browse files Browse the repository at this point in the history
Release 3-22-24
  • Loading branch information
dpaulson45 committed Mar 22, 2024
2 parents 2fd11c0 + ccbbee7 commit 9cba1d7
Show file tree
Hide file tree
Showing 6 changed files with 1,251 additions and 2 deletions.
72 changes: 72 additions & 0 deletions Setup/SetupLogReviewer/Checks/FindContext/Test-SharedConfigDc.ps1
@@ -0,0 +1,72 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

. $PSScriptRoot\..\New-ActionPlan.ps1
. $PSScriptRoot\..\New-ErrorContext.ps1
function Test-SharedConfigDc {
[CmdletBinding()]
param(
[Parameter(ValueFromPipeline = $true)]
[object]
$SetupLogReviewer
)
process {
Write-Verbose "Calling: $($MyInvocation.MyCommand)"
$sharedConfigDc = $SetupLogReviewer | SelectStringLastRunOfExchangeSetup "\[ERROR\] Unable to set shared config DC"
$errorCausedFailure = $SetupLogReviewer | SelectStringLastRunOfExchangeSetup "\[ERROR-REFERENCE\] Id=AllADRolesCommonServiceControl___ee47ab1c06fb47919398e2e95ed99c6c"
$serviceStartedLine = "It appears that the Microsoft Exchange Active Directory Topology service was started on the server and we ran into a different inner exception."
$noteCommon = "NOTE: It is common that the service will not stay started after the initial failure, make sure you keep the Microsoft Exchange Active Directory Topology service running during the entire setup process"
$genericActionPlan = @("Carefully read the inner exception and review the application logs to determine why we can't connect to Active Directory.",
[System.Environment]::NewLine,
" $noteCommon")

if ($null -ne $sharedConfigDc -and
$null -ne $errorCausedFailure) {
# Now that we have this particular error, what matters is the inner exception.
# cSpell:disable
$innerError = $SetupLogReviewer | SelectStringLastRunOfExchangeSetup "\] An error ocurred while setting shared config DC\. Error: (.+)"
$innerExceptionCatch = $SetupLogReviewer | SelectStringLastRunOfExchangeSetup "\] An exception ocurred while setting shared config DC\. Exception: (.+)"
# cSpell:enable

if ($null -ne $innerError) {
$innerErrorValue = $innerError.Matches.Groups[1].Value
$sharedConfigDc.Line + [System.Environment]::NewLine + "Inner Exception: $innerErrorValue" | New-ErrorContext

# cSpell:disable
# coudn't spelled incorrectly in code.
$serviceStopString = "Topology Provider coundn't find the Microsoft Exchange Active Directory Topology service on end point 'TopologyClientTcpEndpoint (localhost)'."
# cSpell:enable
if ($innerErrorValue -eq $serviceStopString) {
New-ActionPlan @(
"1. The service needs to be started prior to setup & during setup. Setup could be stopping and disabling this service preventing setup from working.",
" MAKE SURE IT IS RUNNING DURING THE WHOLE SETUP AFTER COPYING FILES",
"2. After starting the service, make sure it stays running and check the application logs to make sure there are no errors.",
" We could have failed the first time because we couldn't find a suitable domain controller for various number of reasons.",
" If those errors are still there after starting the service, you need to address those prior to trying to run setup again."
)
} else {
New-ActionPlan @(
$serviceStartedLine,
$genericActionPlan
)
}
} elseif ($null -ne $innerExceptionCatch) {
$innerExceptionCatchValue = $innerExceptionCatch.Matches.Groups[1].Value
$sharedConfigDc.Line + [System.Environment]::NewLine + "Inner Exception: $innerExceptionCatchValue" | New-ErrorContext

New-ActionPlan @(
$serviceStartedLine,
$genericActionPlan
)
} else {
$sharedConfigDc.Line | New-ErrorContext
New-ActionPlan @(
"Determined that we found an issue with trying to set the Shared Config DC, but was unable to get find the inner exception.",
"Start the Microsoft Exchange Active Directory Topology service and see if there are any errors in the application log related to the service after it has started.",
"Troubleshoot those error messages prior to trying to run setup again.",
$noteCommon
)
}
}
}
}
7 changes: 7 additions & 0 deletions Setup/Shared/SetupLogReviewerFunctions.ps1
Expand Up @@ -238,6 +238,7 @@ function Get-SetupLogReviewer {
LastSetupRunLine = $validSetupLog.LineNumber
User = $currentLogOnUser.Matches.Groups[1].Value
SetupRunDate = $runDate
SetupMode = "Unknown"
LocalBuildNumber = [string]::Empty
SetupBuildNumber = $setupBuildNumber
}
Expand All @@ -254,5 +255,11 @@ function Get-SetupLogReviewer {
$logReviewer.LocalBuildNumber = $backupLocalInstall.Matches.Groups[1].Value
}

$setupMode = $logReviewer | SelectStringLastRunOfExchangeSetup -Pattern "Command Line Parameter Name='mode', Value='(.+)'\."

if ($null -ne $setupMode) {
$logReviewer.SetupMode = $setupMode.Matches.Groups[1].Value
}

return $logReviewer
}
8 changes: 6 additions & 2 deletions Setup/Shared/SetupLogReviewerLogic.ps1
Expand Up @@ -11,6 +11,7 @@
. $PSScriptRoot\..\SetupLogReviewer\Checks\FindContext\Test-KnownMsiIssuesCheck.ps1
. $PSScriptRoot\..\SetupLogReviewer\Checks\FindContext\Test-OtherWellKnownObjects.ps1
. $PSScriptRoot\..\SetupLogReviewer\Checks\FindContext\Test-PrerequisiteCheck.ps1
. $PSScriptRoot\..\SetupLogReviewer\Checks\FindContext\Test-SharedConfigDc.ps1
. $PSScriptRoot\..\SetupLogReviewer\Checks\FindContext\Write-LastErrorInformation.ps1
. $PSScriptRoot\..\SetupLogReviewer\Checks\Write-Result.ps1
function Invoke-SetupLogReviewer {
Expand Down Expand Up @@ -48,6 +49,7 @@ function Invoke-SetupLogReviewer {
$ranDate = $setupLogReviewer.SetupRunDate

if ($ranDate -lt ([DateTime]::Now.AddDays(-14))) { $color = "Yellow" }
Write-Host "Setup Mode: $($setupLogReviewer.SetupMode)"
Write-Host "Setup.exe Run Date: $ranDate" -ForegroundColor $color
Write-Host "Setup.exe Build Number: $($setupLogReviewer.SetupBuildNumber)"

Expand All @@ -58,9 +60,10 @@ function Invoke-SetupLogReviewer {
$localBuild = New-Object System.Version $setupLogReviewer.LocalBuildNumber -ErrorAction Stop
$setupBuild = New-Object System.Version $setupLogReviewer.SetupBuildNumber -ErrorAction Stop

if ($localBuild -eq $setupBuild -or
if (($localBuild -eq $setupBuild -or
($localBuild.Minor -eq $setupBuild.Minor -and
$localBuild.Build -eq $setupBuild.Build)) {
$localBuild.Build -eq $setupBuild.Build)) -and
($setupLogReviewer.SetupMode -ne "Install")) {
Write-Host "Same build number detected..... if using powershell.exe to start setup. Make sure you do '.\setup.exe'" -ForegroundColor "Red"
}
} catch {
Expand Down Expand Up @@ -91,6 +94,7 @@ function Invoke-SetupLogReviewer {
"Test-OtherWellKnownObjects",
"Test-IsHybridObjectFoundOnPremises",
"Test-InvalidWKObjectTargetException",
"Test-SharedConfigDc",
"Write-LastErrorInformation"
)
}

0 comments on commit 9cba1d7

Please sign in to comment.