Skip to content

Commit e80b9b7

Browse files
authored
Merge branch 'main' into agentV5
2 parents 6d39640 + ccb5813 commit e80b9b7

File tree

4 files changed

+47
-2
lines changed

4 files changed

+47
-2
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
- Pester v5 support for agent checks.
1111

12+
## [3.0.1-preview0025] - 2023-08-28
13+
14+
### Added
15+
16+
- PageVerify check converted to V5 functionality.
17+
1218
### Changed
1319

1420
- For changes in existing functionality.

source/checks/Databasev5.Tests.ps1

+30
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ Describe "Contained Database Auto Close" -Tag ContainedDBAutoClose, CIS, Databas
266266
Describe "Contained Database SQL Authenticated Users" -Tag ContainedDBSQLAuth, CIS, Database -ForEach $InstancesToTest {
267267
$Skip = ($__dbcconfig | Where-Object Name -EQ 'skip.security.ContainedDBSQLAuth').Value
268268

269+
#TODO: something with this?
269270
#if ($version -lt 13 ) { $skip = $true }
270271

271272
Context "Testing contained database to see if sql authenticated users exist on <_.Name>" {
@@ -274,3 +275,32 @@ Describe "Contained Database SQL Authenticated Users" -Tag ContainedDBSQLAuth, C
274275
}
275276
}
276277
}
278+
279+
Describe "Page Verify" -Tag PageVerify, Medium, Database -ForEach $InstancesToTest {
280+
$Skip = ($__dbcconfig | Where-Object Name -EQ 'skip.database.pageverify').Value
281+
Context "Testing page verify on <_.Name>" {
282+
283+
# handle differently depending on major version - not available at all in SQL 2000. 2005 not available on tempdb.
284+
if($psitem.MajorVersion -eq 8) {
285+
It "Database Page verify is not available on SQL 2000 on <_.SqlInstance>" {
286+
$true | Should -BeTrue
287+
}
288+
} elseif ($psitem.MajorVersion -eq 9) {
289+
It "Database <_.Name> should have page verify set to <_.ConfigValues.pageverify> on <_.SqlInstance>" -Skip:$skip -ForEach $psitem.Databases.Where{ if ($Database) { $_.Name -in $Database } else { $psitem.ConfigValues.pageverifyexclude -notcontains $psitem.Name } } {
290+
if($psitem.Name -ne 'tempdb') {
291+
$psitem.PageVerify | Should -Be $psitem.ConfigValues.PageVerify -Because "Page verify helps SQL Server to detect corruption"
292+
} else {
293+
$true | Should -BeTrue
294+
}
295+
}
296+
} else {
297+
It "Database <_.Name> should have page verify set to <_.ConfigValues.pageverify> on <_.SqlInstance>" -Skip:$skip -ForEach $psitem.Databases.Where{ if ($Database) { $_.Name -in $Database } else { $psitem.ConfigValues.pageverifyexclude -notcontains $psitem.Name -and $_.Name -ne 'tempdb'} } {
298+
$psitem.PageVerify | Should -Be $psitem.ConfigValues.PageVerify -Because "Page verify helps SQL Server to detect corruption."
299+
}
300+
#tempdb handled like v4
301+
It "Database Page verify is not available on tempdb on SQL 2005 on <_.SqlInstance>" -Skip:$skip -ForEach $psitem.Databases.Where{ $_.Name -eq 'tempdb' } {
302+
$psitem.PageVerify | Should -Be $psitem.ConfigValues.PageVerify -Because "Page verify helps SQL Server to detect corruption."
303+
}
304+
}
305+
}
306+
}

source/internal/configurations/configuration.ps1

+2
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ Set-PSFConfig -Module dbachecks -Name policy.cluster.registerallprovidersIP -Val
137137
Set-PSFConfig -Module dbachecks -Name policy.dump.maxcount -Value 1 -Initialize -Description "Maximum number of expected dumps"
138138

139139
#pageverify
140+
#TODO: Only 2 part name - should we fix this?
140141
Set-PSFConfig -Module dbachecks -Name policy.pageverify -Value "Checksum" -Initialize -Description "Page verify option should be set to this value"
141142

142143
# InstanceMaxDop
@@ -340,6 +341,7 @@ Set-PSFConfig -Module dbachecks -Name skip.database.status -Validation bool -Val
340341
Set-PSFConfig -Module dbachecks -Name skip.database.compatibilitylevel -Validation bool -Value $false -Initialize -Description "Skip the database compatibility test"
341342
Set-PSFConfig -Module dbachecks -Name skip.database.recoverymodel -Validation bool -Value $false -Initialize -Description "Skip the database recovery model test"
342343
Set-PSFConfig -Module dbachecks -Name skip.database.pseudosimple -Validation bool -Value $false -Initialize -Description "Skip the database PseudoSimple recovery model test"
344+
Set-PSFConfig -Module dbachecks -Name skip.database.pageverify -Validation bool -Value $false -Initialize -Description "Skip the database page verify test"
343345

344346
Set-PSFConfig -Module dbachecks -Name skip.logshiptesting -Validation bool -Value $false -Initialize -Description "Skip the logshipping test"
345347

source/internal/functions/Get-AllDatabaseInfo.ps1

+9-2
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,15 @@ function Get-AllDatabaseInfo {
152152
$containedDbAutoClose = $true
153153
$ConfigValues | Add-Member -MemberType NoteProperty -Name 'contdbautocloseexclude' -Value ($__dbcconfig | Where-Object Name -EQ 'policy.database.contdbautocloseexclude').Value
154154
}
155-
'ContainedDBSQLAuth'{
155+
'ContainedDBSQLAuth' {
156156
$containedDbSqlAuthUsers = $true
157157
$ConfigValues | Add-Member -MemberType NoteProperty -Name 'contdbsqlauthexclude' -Value ($__dbcconfig | Where-Object Name -EQ 'policy.database.contdbsqlauthexclude').Value
158158
}
159+
'PageVerify' {
160+
$pageverify = $true
161+
$ConfigValues | Add-Member -MemberType NoteProperty -Name 'pageverifyexclude' -Value ($__dbcconfig | Where-Object Name -EQ 'policy.database.contdbsqlauthexclude').Value
162+
$ConfigValues | Add-Member -MemberType NoteProperty -Name 'pageverify' -Value ($__dbcconfig | Where-Object Name -EQ 'policy.pageverify').Value
163+
}
159164
Default { }
160165
}
161166

@@ -165,6 +170,7 @@ function Get-AllDatabaseInfo {
165170
InstanceName = $Instance.DbaInstanceName
166171
Name = $Instance.Name
167172
ConfigValues = $ConfigValues
173+
MajorVersion = $Instance.VersionMajor
168174
Databases = $Instance.Databases.Foreach{
169175
[PSCustomObject]@{
170176
Name = $psitem.Name
@@ -194,7 +200,8 @@ function Get-AllDatabaseInfo {
194200
PseudoSimple = @(if ($pseudoSimple) { '' -eq (($psitem.Query('Select last_log_backup_lsn from sys.database_recovery_status where database_id = DB_ID()')).last_log_backup_lsn) })
195201
ContainmentType = @(if ($containedDbAutoClose -or $containedDbSqlAuthUsers) { $psitem.ContainmentType })
196202
ContainedDbAutoClose = @(if ($containedDbAutoClose) { if (($psItem.ContainmentType -ne "NONE") -and ($null -ne $psItem.ContainmentType) -and $psitem.AutoClose) { $true } else { $false } } )
197-
ContainedDbSqlAuthUsers = @(if ($containedDbSqlAuthUsers) { if ($psItem.ContainmentType -ne "NONE" -and ($null -ne $psItem.ContainmentType)) { ($psitem.Users | Where-Object {$_.LoginType -eq "SqlLogin" -and $_.HasDbAccess -eq $true } | Measure-Object ).Count}} )
203+
ContainedDbSqlAuthUsers = @(if ($containedDbSqlAuthUsers) { if ($psItem.ContainmentType -ne "NONE" -and ($null -ne $psItem.ContainmentType)) { ($psitem.Users | Where-Object { $_.LoginType -eq "SqlLogin" -and $_.HasDbAccess -eq $true } | Measure-Object ).Count } } )
204+
PageVerify = @(if ($pageverify) { $psitem.PageVerify })
198205
}
199206
}
200207
}

0 commit comments

Comments
 (0)