Skip to content

Commit

Permalink
Merge pull request #923 from jpomfret/latestBuild
Browse files Browse the repository at this point in the history
Add latestbuild check
  • Loading branch information
jpomfret authored Mar 7, 2023
2 parents fa94622 + 33011d2 commit 8a6e07b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions source/checks/Instancev5.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,15 @@ Describe "Error Log Entries" -Tag ErrorLog, Medium, Instance -ForEach $Instances
}
}

Describe "Latest Build" -Tag LatestBuild, Security, CIS, Medium, Instance -ForEach $InstancesToTest {
$skip = ($__dbcconfig | Where-Object { $_.Name -eq 'skip.instance.latestbuild' }).Value
Context "Testing Latest Build on <_.Name>" {
It "The Latest Build of SQL should be installed on <_.Name>" -Skip:$skip {
$psitem.LatestBuild.Compliant | Should -BeTrue -Because "being patched to the latest version is important"
}
}
}

<#
Describe "TempDB Configuration" -Tags TempDbConfiguration, Medium, Instance -ForEach $InstancesToTest {
Context "Testing TempDB Configuration on $psitem" -Skip:(($__dbcconfig | Where-Object { $_.Name
Expand Down
6 changes: 6 additions & 0 deletions source/internal/functions/NewGet-AllInstanceInfo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ function NewGet-AllInstanceInfo {
# It is not enough to check the CreateDate on the log, you must check the LogDate on every error record as well.
$ErrorLogCount = (Get-ErrorLogEntry | Where-Object { $psitem.LogDate -gt (Get-Date).AddDays( - $LogWindow) }).Count
}
'LatestBuild' {
$LatestBuild = Test-DbaBuild -SqlInstance $Instance -Latest
}
'TempDbConfiguration' {
$TempDBTest = Test-DbaTempDbConfig -SqlInstance $Instance
}
Expand Down Expand Up @@ -373,6 +376,9 @@ function NewGet-AllInstanceInfo {
logWindow = $logWindow
}
InstanceConnection = $InstanceConnection
LatestBuild = [PSCustomObject]@{
Compliant = $LatestBuild.Compliant
}
# TempDbConfig = [PSCustomObject]@{
# TF118EnabledCurrent = $tempDBTest[0].CurrentSetting
# TF118EnabledRecommended = $tempDBTest[0].Recommended
Expand Down

0 comments on commit 8a6e07b

Please sign in to comment.