Skip to content

Commit

Permalink
Add InstalledDate for SUs
Browse files Browse the repository at this point in the history
  • Loading branch information
dpaulson45 committed Aug 6, 2024
1 parent cb21ece commit 6554c55
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,20 @@ function Invoke-AnalyzerExchangeInformation {
Add-AnalyzedResultInformation @params
}

if ($null -ne $exchangeInformation.BuildInformation.KBsInstalled) {
if ($null -ne $exchangeInformation.BuildInformation.KBsInstalledInfo.PackageName) {
Add-AnalyzedResultInformation -Name "Exchange IU or Security Hotfix Detected" @baseParams
$problemKbFound = $false
$problemKbName = "KB5029388"

foreach ($kb in $exchangeInformation.BuildInformation.KBsInstalled) {
foreach ($kbInfo in $exchangeInformation.BuildInformation.KBsInstalledInfo) {
$kbName = $kbInfo.PackageName
$params = $baseParams + @{
Details = $kb
Details = "$kbName - Installed on $($kbInfo.InstalledDate)"
DisplayCustomTabNumber = 2
}
Add-AnalyzedResultInformation @params

if ($kb.Contains($problemKbName)) {
if ($kbName.Contains($problemKbName)) {
$problemKbFound = $true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ function Invoke-AnalyzerSecurityCve-MarchSuSpecial {
#Description: March 2021 Exchange vulnerabilities Security Update (SU) check for outdated version (CUs)
#Affected Exchange versions: Exchange 2013, Exchange 2016, Exchange 2016 (we only provide this special SU for these versions)
#Fix: Update to a supported CU and apply KB5000871
$march2021SUInstalled = $null -ne $SecurityObject.ExchangeInformation.BuildInformation.KBsInstalled -and
$SecurityObject.ExchangeInformation.BuildInformation.KBsInstalled -like "*KB5000871*"
$march2021SUInstalled = $null -ne $SecurityObject.ExchangeInformation.BuildInformation.KBsInstalledInfo.PackageName -and
$SecurityObject.ExchangeInformation.BuildInformation.KBsInstalledInfo.PackageName -like "*KB5000871*"
$ex2019 = "Exchange2019"
$ex2016 = "Exchange2016"
$ex2013 = "Exchange2013"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function Get-ExchangeInformation {
CU = $versionInformation.CU
ExchangeSetup = $exSetupDetails
VersionInformation = $versionInformation
KBsInstalled = [array](Get-ExchangeUpdates -Server $Server -ExchangeMajorVersion $versionInformation.MajorVersion)
KBsInstalledInfo = [array](Get-ExchangeUpdates -Server $Server -ExchangeMajorVersion $versionInformation.MajorVersion)
}

$dependentServices = (Get-ExchangeDependentServices -MachineName $Server)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,18 @@ function Get-ExchangeUpdates {
$IU = $RegKey.GetSubKeyNames()
if ($null -ne $IU) {
Write-Verbose "Detected fixes installed on the server"
$fixes = @()
$installedUpdates = New-Object System.Collections.Generic.List[object]
foreach ($key in $IU) {
$IUKey = $RegKey.OpenSubKey($key)
$IUName = $IUKey.GetValue("PackageName")
Write-Verbose "Found: $IUName"
$fixes += $IUName
$IUInstalledDate = $IUKey.GetValue("InstalledDate")
$installedUpdates.Add(([PSCustomObject]@{
PackageName = $IUName
InstalledDate = $IUInstalledDate
}))
}
return $fixes
return $installedUpdates
} else {
Write-Verbose "No IUs found in the registry"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Describe "Testing Health Checker by Mock Data Imports" {
Assert-MockCalled Get-WmiObjectHandler -Exactly 6
Assert-MockCalled Invoke-ScriptBlockHandler -Exactly 5
Assert-MockCalled Get-RemoteRegistryValue -Exactly 25
Assert-MockCalled Get-RemoteRegistrySubKey -Exactly 1
Assert-MockCalled Get-NETFrameworkVersion -Exactly 1
Assert-MockCalled Get-DotNetDllFileVersions -Exactly 1
Assert-MockCalled Get-NicPnpCapabilitiesSetting -Exactly 1
Expand All @@ -75,7 +76,6 @@ Describe "Testing Health Checker by Mock Data Imports" {
Assert-MockCalled Get-AllTlsSettings -Exactly 1
Assert-MockCalled Get-SmbServerConfiguration -Exactly 1
Assert-MockCalled Get-ExchangeAppPoolsInformation -Exactly 1
Assert-MockCalled Get-ExchangeUpdates -Exactly 1
Assert-MockCalled Get-ExchangeDomainsAclPermissions -Exactly 1
Assert-MockCalled Get-ExchangeAdSchemaClass -Exactly 2
Assert-MockCalled Get-ExchangeServer -Exactly 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,20 @@ Mock Get-RemoteRegistryValue {
}
}

Mock Get-RemoteRegistrySubKey {
param(
[string]$MachineName,
[string]$SubKey
)

switch ($SubKey) {
"SOFTWARE\Microsoft\Updates\Exchange 2013" { return $null }
"SOFTWARE\Microsoft\Updates\Exchange 2016" { return $null }
"SOFTWARE\Microsoft\Updates\Exchange 2019" { return $null }
default { throw "Failed to find SubKey: $SubKey" }
}
}

Mock Get-NETFrameworkVersion {
return [PSCustomObject]@{
FriendlyName = "4.8"
Expand Down Expand Up @@ -199,10 +213,6 @@ Mock Get-ExchangeAppPoolsInformation {
return Import-Clixml "$Script:MockDataCollectionRoot\Exchange\GetExchangeAppPoolsInformation.xml"
}

Mock Get-ExchangeUpdates {
return $null
}

Mock Get-ExchangeAdSchemaClass -ParameterFilter { $SchemaClassName -eq "ms-Exch-Storage-Group" } {
return Import-Clixml "$Script:MockDataCollectionRoot\Exchange\GetExchangeAdSchemaClass_ms-Exch-Storage-Group.xml"
}
Expand Down

0 comments on commit 6554c55

Please sign in to comment.