Skip to content

Commit 8a6e07b

Browse files
authored
Merge pull request #923 from jpomfret/latestBuild
Add latestbuild check
2 parents fa94622 + 33011d2 commit 8a6e07b

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

source/checks/Instancev5.Tests.ps1

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,15 @@ Describe "Error Log Entries" -Tag ErrorLog, Medium, Instance -ForEach $Instances
346346
}
347347
}
348348

349+
Describe "Latest Build" -Tag LatestBuild, Security, CIS, Medium, Instance -ForEach $InstancesToTest {
350+
$skip = ($__dbcconfig | Where-Object { $_.Name -eq 'skip.instance.latestbuild' }).Value
351+
Context "Testing Latest Build on <_.Name>" {
352+
It "The Latest Build of SQL should be installed on <_.Name>" -Skip:$skip {
353+
$psitem.LatestBuild.Compliant | Should -BeTrue -Because "being patched to the latest version is important"
354+
}
355+
}
356+
}
357+
349358
<#
350359
Describe "TempDB Configuration" -Tags TempDbConfiguration, Medium, Instance -ForEach $InstancesToTest {
351360
Context "Testing TempDB Configuration on $psitem" -Skip:(($__dbcconfig | Where-Object { $_.Name

source/internal/functions/NewGet-AllInstanceInfo.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,9 @@ function NewGet-AllInstanceInfo {
270270
# It is not enough to check the CreateDate on the log, you must check the LogDate on every error record as well.
271271
$ErrorLogCount = (Get-ErrorLogEntry | Where-Object { $psitem.LogDate -gt (Get-Date).AddDays( - $LogWindow) }).Count
272272
}
273+
'LatestBuild' {
274+
$LatestBuild = Test-DbaBuild -SqlInstance $Instance -Latest
275+
}
273276
'TempDbConfiguration' {
274277
$TempDBTest = Test-DbaTempDbConfig -SqlInstance $Instance
275278
}
@@ -373,6 +376,9 @@ function NewGet-AllInstanceInfo {
373376
logWindow = $logWindow
374377
}
375378
InstanceConnection = $InstanceConnection
379+
LatestBuild = [PSCustomObject]@{
380+
Compliant = $LatestBuild.Compliant
381+
}
376382
# TempDbConfig = [PSCustomObject]@{
377383
# TF118EnabledCurrent = $tempDBTest[0].CurrentSetting
378384
# TF118EnabledRecommended = $tempDBTest[0].Recommended

0 commit comments

Comments
 (0)