Skip to content

Commit

Permalink
Merge pull request #1971 from microsoft/dpaul-HcMissingExSetup
Browse files Browse the repository at this point in the history
Handle missing ExSetup on server
  • Loading branch information
dpaulson45 authored Feb 7, 2024
2 parents 68d9882 + 50bb2a3 commit dbfbb0f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,17 @@ function Invoke-AnalyzerExchangeInformation {
}
}

# If the ExSetup wasn't found, we need to report that.
if ($exchangeInformation.BuildInformation.ExchangeSetup.FailedGetExSetup -eq $true) {
$params = $baseParams + @{
Name = "Warning"
Details = "Didn't detect ExSetup.exe on the server. This might mean that setup didn't complete correctly the last time it was run."
DisplayCustomTabNumber = 2
DisplayWriteType = "Yellow"
}
Add-AnalyzedResultInformation @params
}

if ($null -ne $exchangeInformation.BuildInformation.KBsInstalled) {
Add-AnalyzedResultInformation -Name "Exchange IU or Security Hotfix Detected" @baseParams
$problemKbFound = $false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,20 @@ function Get-ExSetupDetails {
Write-Verbose "Calling: $($MyInvocation.MyCommand)"
$exSetupDetails = [string]::Empty
function Get-ExSetupDetailsScriptBlock {
Get-Command ExSetup | ForEach-Object { $_.FileVersionInfo }
try {
Get-Command ExSetup -ErrorAction Stop | ForEach-Object { $_.FileVersionInfo }
} catch {
try {
Write-Verbose "Failed to find ExSetup by environment path locations. Attempting manual lookup."
$installDirectory = (Get-ItemProperty HKLM:\SOFTWARE\Microsoft\ExchangeServer\v15\Setup -ErrorAction Stop).MsiInstallPath

if ($null -ne $installDirectory) {
Get-Command ([System.IO.Path]::Combine($installDirectory, "bin\ExSetup.exe")) -ErrorAction Stop | ForEach-Object { $_.FileVersionInfo }
}
} catch {
Write-Verbose "Failed to find ExSetup, need to fallback."
}
}
}

$exSetupDetails = Invoke-ScriptBlockHandler -ComputerName $Server -ScriptBlock ${Function:Get-ExSetupDetailsScriptBlock} -ScriptBlockDescription "Getting ExSetup remotely" -CatchActionFunction ${Function:Invoke-CatchActions}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,21 @@ function Get-ExchangeInformation {
$getExchangeServer = (Get-ExchangeServer -Identity $Server -Status)
$exchangeCertificates = Get-ExchangeServerCertificates -Server $Server
$exSetupDetails = Get-ExSetupDetails -Server $Server
$versionInformation = (Get-ExchangeBuildVersionInformation -FileVersion ($exSetupDetails.FileVersion))

if ($null -eq $exSetupDetails) {
# couldn't find ExSetup.exe this should be rare so we are just going to handle this by displaying the AdminDisplayVersion from Get-ExchangeServer
$versionInformation = (Get-ExchangeBuildVersionInformation -AdminDisplayVersion $getExchangeServer.AdminDisplayVersion)
$exSetupDetails = [PSCustomObject]@{
FileVersion = $versionInformation.BuildVersion.ToString()
FileBuildPart = $versionInformation.BuildVersion.Build
FilePrivatePart = $versionInformation.BuildVersion.Revision
FileMajorPart = $versionInformation.BuildVersion.Major
FileMinorPart = $versionInformation.BuildVersion.Minor
FailedGetExSetup = $true
}
} else {
$versionInformation = (Get-ExchangeBuildVersionInformation -FileVersion ($exSetupDetails.FileVersion))
}

$buildInformation = [PSCustomObject]@{
ServerRole = (Get-ServerRole -ExchangeServerObj $getExchangeServer)
Expand Down

0 comments on commit dbfbb0f

Please sign in to comment.