Skip to content

Commit ceef968

Browse files
Merge branch 'main' into agentV5
2 parents 2404994 + 7637efe commit ceef968

File tree

12 files changed

+430
-28
lines changed

12 files changed

+430
-28
lines changed

CONTRIBUTING.md

Lines changed: 75 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Contributing
22

3-
## TODO
43
## Welcome
54

65
Before we go any further, thanks for being here. Thanks for using dbachecks and especially thanks
@@ -34,7 +33,7 @@ In order to use the devcontainer there are a few things you need to get started.
3433
- [Docker](https://www.docker.com/get-started)
3534
- [git](https://git-scm.com/downloads)
3635
- [VSCode](https://code.visualstudio.com/download)
37-
- [`Remote Development` Extension for VSCode](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack)
36+
- [Remote Development Extension for VSCode](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack)
3837

3938
### Setup
4039

@@ -61,9 +60,81 @@ so that could take a hot second depending on your internet speeds.
6160
1. The first time you do this it may take a little, and you'll need an internet connection, as it'll download the container images used in our demos
6261
6362
### Develop & Build
64-
TODO: sampler instructions - similar to /workspace/developing/Howto.md
6563
66-
### Rebuild
64+
We are using the [Sampler](https://github.com/gaelcolas/Sampler) Powershell Module to structure our module.
65+
This makes it easier to develop and test the module locally.
66+
67+
The workflow for using this and developing the code - for example to add a new Database level check you could follow
68+
this guide.
69+
70+
1. Download the repo locally and create a new branch to develop on
71+
```PowerShell
72+
git checkout -b newStuff # give it a proper name!
73+
```
74+
75+
1. Develop in the source repository, to add a check you need to add the following code:
76+
- add check code to `source/checks/DatabaseV5.Tests.ps1`
77+
- add required configurations to `source/internal/configurations/configuration.ps1`
78+
- `skip.database.checkName`
79+
- `policy.database.checkNameExcludeDb`
80+
- add required properties to object info to `source/internal/functions/Get-AllDatabaseInfo.ps1`
81+
82+
1. Build the module
83+
```PowerShell
84+
./build.ps1 -Tasks build
85+
```
86+
87+
1. Sampler automatically adds the new version to your path you can prove that with the following code:
88+
```PowerShell
89+
get-module dbachecks -ListAvailable | Select-Object Name, ModuleBase
90+
```
91+
92+
1. Import new version of the module
93+
```PowerShell
94+
Import-Module dbachecks -force
95+
```
96+
97+
1. Test out the new code
98+
```PowerShell
99+
# save the password to make for easy connections
100+
$password = ConvertTo-SecureString "dbatools.IO" -AsPlainText -Force
101+
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "sqladmin", $password
102+
103+
$show = 'All'
104+
$checks = 'RecoveryModel' # <-- change this to your new check name
105+
106+
$sqlinstances = 'localhost,7401', 'localhost,7402', 'localhost,7403'
107+
#$sqlinstances = 'dbachecks1', 'dbachecks2', 'dbachecks3' # need client aliases for this to work New-DbaClientAlias
108+
109+
# Run v5 checks
110+
$v5code = Invoke-DbcCheck -SqlInstance $Sqlinstances -SqlCredential $cred -Check $Checks -legacy $false -Show $show -PassThru -Verbose
111+
```
112+
113+
1. If you are working on the v4 --> v5 upgrade you can also confirm your v5 test results match v4 with the following
114+
```PowerShell
115+
# save the password to make for easy connections
116+
$password = ConvertTo-SecureString "dbatools.IO" -AsPlainText -Force
117+
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "sqladmin", $password
118+
119+
$show = 'All'
120+
$checks = 'RecoveryModel' # <-- change this to your new check name
121+
122+
$sqlinstances = 'localhost,7401', 'localhost,7402', 'localhost,7403'
123+
#$sqlinstances = 'dbachecks1', 'dbachecks2', 'dbachecks3' # need client aliases for this to work New-DbaClientAlias
124+
125+
# Check results of the tests - are we testing the same things with the same results for v4 & v5
126+
Invoke-PerfAndValidateCheck -SQLInstances $sqlinstances -Checks $Checks
127+
# Include the specific details for the perf testing
128+
Invoke-PerfAndValidateCheck -SQLInstances $sqlinstances -Checks $Checks -PerfDetail
129+
# Include the test results - this helps troubleshooting if your tests aren't the same
130+
Invoke-PerfAndValidateCheck -SQLInstances $sqlinstances -Checks $Checks -showTestResults
131+
```
132+
133+
1. Once you are happy with your code, push your branch to GitHub and create a PR against the dbachecks repo.
134+
135+
1. Thanks!
136+
137+
### Rebuild your devcontainer
67138
68139
The only way to properly rebuild to ensure that all volumes etc are removed is to open up a console
69140
or PowerShell window outside of the devcontainer and run the following:

containers/JessAndBeard.psm1

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2304,8 +2304,9 @@ New Code runs in {2} % of the time
23042304
Write-PSFMessage -Message $savingMessage -Level Output
23052305

23062306
##validate we got the right answers too
2307-
2308-
If (Compare-Object $v5code.Configuration.Filter.Tag.Value $v4code.TagFilter) {
2307+
[System.Collections.ArrayList]$v5CodeTags = $v5code.Configuration.Filter.Tag.Value
2308+
$v5CodeTags.Remove('FailedConnections')
2309+
If (Compare-Object $v5CodeTags $v4code.TagFilter) {
23092310
$Message = "
23102311
Uh-Oh - The Tag filters between v4 and v5 are not the same somehow.
23112312
For v4 We returned
@@ -2427,7 +2428,12 @@ For v4 We Passed
24272428
and
24282429
for v4 we Passed
24292430
{1} tests
2430-
{2}" -f $v4code.PassedCount, $v5Passed, $messageAppend
2431+
{2}
2432+
v4 TestNames
2433+
{3}
2434+
v5 TestNames
2435+
{4}
2436+
" -f $v4code.PassedCount, $v5Passed, $messageAppend, ($v4code.TestResult.Where{$_.Result -eq 'Passed'}.Name |Out-String),($v5code.Passed.ExpandedName |Out-String)
24312437
Write-PSFMessage -Message $Message -Level Warning
24322438
} else {
24332439
$message = "
@@ -2444,7 +2450,11 @@ For v4 We Failed
24442450
and
24452451
for v4 we Failed
24462452
{1} tests
2447-
" -f $v4code.FailedCount, $v5failed
2453+
v4 TestNames
2454+
{2}
2455+
v5 TestNames
2456+
{3}
2457+
" -f $v4code.FailedCount, $v5failed,($v4code.TestResult.Where{$_.Result -eq 'Failed'}.Name |Out-String),($v5code.Failed.ExpandedName |Out-String)
24482458
Write-PSFMessage -Message $Message -Level Warning
24492459
} else {
24502460
$message = "
@@ -2459,9 +2469,13 @@ Uh-Oh - The total tests Skipped between v4 and v5 are not the same somehow.
24592469
For v4 We Skipped
24602470
{0} tests
24612471
and
2462-
for v4 we Skipped
2463-
{1} tests
2464-
{2}" -f $v4code.SkippedCount, $v5skipped, $messageAppend
2472+
For v5 we Skipped
2473+
{1}
2474+
v4 TestNames
2475+
{3}
2476+
v5 TestNames
2477+
{4}
2478+
{2}" -f $v4code.SkippedCount, $v5skipped, $messageAppend,($v4code.TestResult.Where{$_.Result -eq 'Skipped'}.Name |Out-String),($v5code.Skipped.ExpandedName |Out-String)
24652479
Write-PSFMessage -Message $Message -Level Warning
24662480
} else {
24672481
$message = "

containers/base/profile.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ function Load-Profile {
5959
)
6060
$global:__currentTheme = (Get-Random -InputObject $themes)
6161
function global:Get-CurrentPoshTheme { $__currentTheme }
62-
Set-PoshPrompt -Theme $__currentTheme
63-
62+
# Set-PoshPrompt -Theme $__currentTheme
63+
Set-PoshPrompt -Theme 'chips'
6464
if ($psstyle) {
6565
$psstyle.FileInfo.Directory = $psstyle.FileInfo.Executable = $psstyle.FileInfo.SymbolicLink = ""
6666
$PSStyle.FileInfo.Extension.Clear()

developing/Oslo Demo.ps1

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Oslo Demo
2+
3+
./build.ps1 -tasks build
4+
5+
#region setup
6+
$containers = $SQLInstances = $dbachecks1, $dbachecks2, $dbachecks3 = 'dbachecks1', 'dbachecks2', 'dbachecks3'
7+
$password = ConvertTo-SecureString "dbatools.IO" -AsPlainText -Force
8+
$cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "sqladmin", $password
9+
$show = 'All'
10+
#endregion
11+
12+
#region What do we have?
13+
14+
Get-DbaDatabase -SqlInstance $Sqlinstances -SqlCredential $cred -ExcludeSystem | Select-Object Sqlinstance, DatabaseName, Status
15+
16+
Get-DbaAgentJob -SqlInstance $Sqlinstances -SqlCredential $cred | Select-Object Sqlinstance, Name, Enabled
17+
#end region
18+
19+
Get-DbaLastBackup -SqlInstance $Sqlinstances -SqlCredential $cred | Select-Object Sqlinstance, Database, LastFullBackup | Format-Table
20+
21+
# lets run a couple of tests
22+
23+
# this one shows that the old existing code will work
24+
# the legacy switch is set to true by default
25+
26+
Invoke-DbcCheck -SqlInstance $Sqlinstances -SqlCredential $cred -Check InstanceConnection, DatabaseStatus -Show $show
27+
28+
# So lets show the shiny new faster code - legacy switch set to false
29+
30+
Invoke-DbcCheck -SqlInstance $Sqlinstances -SqlCredential $cred -Check InstanceConnection, DatabaseStatus -Show $show -legacy $false
31+
32+
33+
# The Authentication check failed but we would like to pass - lets set config
34+
Set-DbcConfig -Name policy.connection.authscheme -Value SQL
35+
36+
# run again
37+
38+
Invoke-DbcCheck -SqlInstance $Sqlinstances -SqlCredential $cred -Check InstanceConnection, DatabaseStatus -Show $show -legacy $false
39+
40+
# Hmmm, we know that we will never be able to remote onto these containers so let talk about skipping. No Claudio not that sort of skipping!!
41+
Set-DbcConfig -Name skip.connection.remoting -Value $true
42+
43+
# run again
44+
45+
Invoke-DbcCheck -SqlInstance $Sqlinstances -SqlCredential $cred -Check InstanceConnection, DatabaseStatus -Show $show -legacy $false
46+
47+
# So much quicker !!! OK for one check it will be slower. For two it will probably be about the same but for 3 or more it will be quicker. Much quicket. Exrapolate that to 100 checks and a 1000 instances you can see the difference.
48+
49+
# This is how we know - We perf test our PowerShell code
50+
# This will take about 80-100 seconds to run so run first then talk!
51+
52+
$Checks = 'ErrorLogCount', 'XpCmdShellDisabled', 'WhoIsActiveInstalled', 'CLREnabled', 'TwoDigitYearCutoff', 'MaxDopInstance', 'ErrorLogCount', 'ModelDbGrowth', 'DefaultBackupCompression', 'SaExist', 'SaDisabled', 'SaRenamed', 'DefaultFilePath', 'AdHocDistributedQueriesEnabled', 'AdHocWorkload', 'DefaultTrace', 'OleAutomationProceduresDisabled', 'CrossDBOwnershipChaining', 'ScanForStartupProceduresDisabled', 'RemoteAccessDisabled', 'SQLMailXPsDisabled', 'DAC', 'OLEAutomation', 'ServerNameMatch', 'OrphanedFile', 'MaxMemory', 'PublicPermission'
53+
54+
Invoke-PerfAndValidateCheck -Checks $Checks
55+
56+
# I want to use the results in a different way
57+
58+
# ok lets run the checks and save the out put to a variable so that we can show you what happens. Notice we need the -PassThru switch
59+
60+
$CheckResults = Invoke-DbcCheck -SqlInstance $Sqlinstances -SqlCredential $cred -Check InstanceConnection, DatabaseStatus -Show $show -legacy $false -PassThru
61+
62+
# this is our base results object
63+
$CheckResults
64+
65+
# lets convert it to something useful
66+
67+
$SomethingUseful = $CheckResults | Convert-DbcResult
68+
69+
$SomethingUseful
70+
$SomethingUseful | Format-Table
71+
72+
$SomethingUseful | Select-Object -First 1
73+
74+
# Label huh - what is that?
75+
# label these results so that they can be filtered later
76+
77+
$Coffee = $CheckResults | Convert-DbcResult -Label 'CoffeeFilter'
78+
79+
$Coffee | Select-Object -First 1
80+
81+
# Now we can set those to a file if we want
82+
83+
$CheckResults | Convert-DbcResult -Label 'CoffeeFilter' | Set-DbcFile -FileType Json -FilePath . -FileName oslo -Verbose
84+
$CheckResults | Convert-DbcResult -Label 'Whiskey' | Set-DbcFile -FileType Json -FilePath . -FileName oslo -Append
85+
86+
code ./oslo.json
87+
88+
# or put them into a database table
89+
90+
$CheckResults | Convert-DbcResult -Label 'CoffeeFilter' | Write-DbcTable -SqlInstance dbachecks1 -SqlCredential $cred -Database tempdb -Verbose
91+
92+
Invoke-DbaQuery -SqlInstance dbachecks1 -SqlCredential $cred -Database tempdb -Query 'SELECT * FROM CheckResults'
93+
94+
# YOU CANT DO THIS FROM HERE - Open Windows terminal on the host and run
95+
96+
Start-DbcPowerBi -FromDatabase
97+
98+
# then use localhost,7401 tempdb and u:sqladmin p:dbatools.IO
99+
100+
# question turn off a container adn talk about hte fails?
101+
102+
103+
## made some funky results for the Power Bi
104+
105+
$CheckResults = Invoke-DbcCheck -SqlInstance $Sqlinstances -SqlCredential $cred -Check Instance, Database -Show $show -legacy $false -PassThru
106+
107+
$CheckResults | Convert-DbcResult -Label 'DatabaseInstance' | Write-DbcTable -SqlInstance dbachecks1 -SqlCredential $cred -Database tempdb -Verbose
108+
109+
$CheckResults = Invoke-DbcCheck -SqlInstance $Sqlinstances -SqlCredential $cred -Check compatibilitylevel -Show $show -legacy $false -PassThru

developing/Robs-Instance.ps1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
$Checks = 'ErrorLogCount', 'XESessionExists', 'XESessionStopped', 'XpCmdShellDisabled', 'WhoIsActiveInstalled', 'CLREnabled', 'TwoDigitYearCutoff', 'MaxDopInstance', 'ErrorLogCount', 'ModelDbGrowth', 'DefaultBackupCompression', 'SaExist', 'SaDisabled', 'SaRenamed', 'DefaultFilePath', 'AdHocDistributedQueriesEnabled', 'AdHocWorkload', 'DefaultTrace', 'OleAutomationProceduresDisabled', 'CrossDBOwnershipChaining', 'ScanForStartupProceduresDisabled', 'RemoteAccessDisabled', 'SQLMailXPsDisabled', 'DAC', 'OLEAutomation', 'ServerNameMatch', 'OrphanedFile', 'MaxMemory', 'NetworkLatency'
1+
./build.ps1 -Tasks build
2+
3+
$Checks = 'ErrorLogCount', 'XESessionExists', 'XESessionStopped', 'XpCmdShellDisabled', 'WhoIsActiveInstalled', 'CLREnabled', 'TwoDigitYearCutoff', 'MaxDopInstance', 'ErrorLogCount', 'ModelDbGrowth', 'DefaultBackupCompression', 'SaExist', 'SaDisabled', 'SaRenamed', 'DefaultFilePath', 'AdHocDistributedQueriesEnabled', 'AdHocWorkload', 'DefaultTrace', 'OleAutomationProceduresDisabled', 'CrossDBOwnershipChaining', 'ScanForStartupProceduresDisabled', 'RemoteAccessDisabled', 'SQLMailXPsDisabled', 'DAC', 'OLEAutomation', 'ServerNameMatch', 'OrphanedFile', 'MaxMemory', 'NetworkLatency', 'PublicPermission'
24

35
$Checks = 'XESessionRunningAllowed', 'XESessionRunning', 'XESessionRunningAllowed', 'XESessionExists', 'XESessionStopped', 'XpCmdShellDisabled'
46
$Checks = 'TraceFlagsNotExpected', 'TraceFlagsExpected'
@@ -18,6 +20,9 @@ $Checks = 'SuspectPageLimit'
1820
$Checks = 'SupportedBuild'
1921
$Checks = 'LoginMustChange'
2022
$Checks = 'LoginAuditSuccessful', 'LoginAuditFailed'
23+
Set-DbcConfig -Name skip.security.PublicPermission -Value $false
24+
$Checks = 'PublicRolePermission'
25+
$Checks = 'PUblicPermission'
2126

2227
Invoke-PerfAndValidateCheck -Checks $Checks
2328
Invoke-PerfAndValidateCheck -Checks $Checks -PerfDetail

source/checks/Databasev5.Tests.ps1

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,17 @@ Describe "Suspect Page" -Tag SuspectPage, High , Database -ForEach $InstancesToT
5858
}
5959

6060
Describe "Database Collation" -Tag DatabaseCollation, High, Database -ForEach $InstancesToTest {
61+
#TODO: Should we have a skip option for each IT block?
6162
$skip = ($__dbcconfig | Where-Object { $_.Name -eq 'skip.database.databasecollation' }).Value
6263
Context "Testing database collation on <_.Name>" {
6364
It "Database <_.Name> collation <_.Collation> should match server collation <_.ServerCollation> on <_.SqlInstance>" -Skip:$skip -ForEach $psitem.Databases.Where{ if ($Database) { $_.Name -in $Database } else { $psitem.ConfigValues.wrongcollation -notcontains $PsItem.Name } } {
6465
$psitem.ServerCollation | Should -Be $psitem.Collation -Because "You will get collation conflict errors in tempdb"
6566
}
6667

6768
# wrong collation set
68-
It "Database <_.Name> collation <_.Collation> should not match server collation <_.ServerCollation> on <_.SqlInstance>" -ForEach $psitem.Databases.Where{ $_.Name -in $psitem.ConfigValues.wrongcollation } {
69+
It "Database <_.Name> collation <_.Collation> should not match server collation <_.ServerCollation> on <_.SqlInstance>" -Skip:$skip -ForEach $psitem.Databases.Where{ $_.Name -in $psitem.ConfigValues.wrongcollation } {
6970
$psitem.ServerCollation | Should -Not -Be $psitem.Collation -Because "You have defined the database to have another collation then the server. You will get collation conflict errors in tempdb"
7071
}
71-
7272
}
7373
}
7474

@@ -216,7 +216,7 @@ Describe "Query Store Disabled" -Tag QueryStoreDisabled, Medium, Database -ForEa
216216
Describe "Compatibility Level" -Tag CompatibilityLevel, High, Database -ForEach $InstancesToTest {
217217
$Skip = ($__dbcconfig | Where-Object Name -EQ 'skip.database.compatibilitylevel').Value
218218

219-
Context "Compatibility level matches server compatibility level" {
219+
Context "Compatibility level matches server compatibility level on <_.Name>" {
220220
It "Database <_.Name> has the expected compatibility level on <_.SqlInstance>" -Skip:$skip -ForEach $psitem.Databases.Where{ if ($Database) { $_.Name -in $Database } else { $psitem.ConfigValues.compatexclude -notcontains $psitem.Name } } {
221221
$psitem.CompatibilityLevel | Should -Be $psitem.ServerLevel -Because "it means you are on the appropriate compatibility level for your SQL Server version to use all available features."
222222
}
@@ -226,7 +226,7 @@ Describe "Compatibility Level" -Tag CompatibilityLevel, High, Database -ForEach
226226
Describe "Guest User" -Tag GuestUserConnect, Security, CIS, Medium, Database -ForEach $InstancesToTest {
227227
$Skip = ($__dbcconfig | Where-Object Name -EQ 'skip.security.guestuserconnect').Value
228228

229-
Context "Testing Guest user has CONNECT permission" {
229+
Context "Testing Guest user has CONNECT permission on <_.Name>" {
230230
It "Database Guest user should return no CONNECT permissions in <_.Name> on <_.SqlInstance>" -Skip:$skip -ForEach $psitem.Databases.Where{ if ($Database) { $_.Name -in $Database } else { $psitem.ConfigValues.guestuserexclude -notcontains $psitem.Name } } {
231231
$psitem.GuestUserConnect | Should -BeFalse -Because "we don't want the guest user to have connect access to our database."
232232
}
@@ -236,9 +236,41 @@ Describe "Guest User" -Tag GuestUserConnect, Security, CIS, Medium, Database -Fo
236236
Describe "Recovery Model" -Tag RecoveryModel, DISA, Medium, Database -ForEach $InstancesToTest {
237237
$Skip = ($__dbcconfig | Where-Object Name -EQ 'skip.database.recoverymodel').Value
238238

239-
Context "Testing Recovery Model" {
239+
Context "Testing Recovery Model on <_.Name>" {
240240
It "Database <_.Name> should be set to <_.ConfigValues.recoverymodeltype> on <_.SqlInstance>" -Skip:$skip -ForEach $psitem.Databases.Where{ if ($Database) { $_.Name -in $Database } else { $psitem.ConfigValues.recoverymodelexclude -notcontains $psitem.Name } } {
241241
$psitem.RecoveryModel | Should -Be $psitem.ConfigValues.recoverymodeltype -Because "You expect this recovery model."
242242
}
243243
}
244244
}
245+
246+
Describe "PseudoSimple Recovery Model" -Tag PseudoSimple, Medium, Database -ForEach $InstancesToTest {
247+
$Skip = ($__dbcconfig | Where-Object Name -EQ 'skip.database.pseudosimple').Value
248+
249+
Context "Testing database is not in PseudoSimple recovery model on <_.Name>" {
250+
It "Database <_.Name> has PseudoSimple recovery model equal false on <_.SqlInstance>" -Skip:$skip -ForEach $psitem.Databases.Where{ if ($Database) { $_.Name -in $Database -and $_.RecoveryModel -eq 'Full' } else { $psitem.ConfigValues.pseudosimpleexclude -notcontains $psitem.Name -and $_.RecoveryModel -eq 'Full' } } {
251+
$psitem.PseudoSimple | Should -BeFalse -Because "PseudoSimple means that a FULL backup has not been taken and the database is still effectively in SIMPLE mode"
252+
}
253+
}
254+
}
255+
256+
Describe "Contained Database Auto Close" -Tag ContainedDBAutoClose, CIS, Database -ForEach $InstancesToTest {
257+
$Skip = ($__dbcconfig | Where-Object Name -EQ 'skip.security.containedbautoclose').Value
258+
259+
Context "Testing contained database auto close option on <_.Name>" {
260+
It "Database <_.Name> should have auto close set to false on <_.SqlInstance>" -Skip:$skip -ForEach $psitem.Databases.Where{ if ($Database) { $_.Name -in $Database -and $_.ContainmentType -ne "NONE" } else { $psitem.ConfigValues.contdbautocloseexclude -notcontains $psitem.Name -and $_.ContainmentType -ne "NONE" } } {
261+
$psitem.ContainedDbAutoClose | Should -BeFalse -Because "Contained Databases should have auto close set to false for CIS compliance."
262+
}
263+
}
264+
}
265+
266+
Describe "Contained Database SQL Authenticated Users" -Tag ContainedDBSQLAuth, CIS, Database -ForEach $InstancesToTest {
267+
$Skip = ($__dbcconfig | Where-Object Name -EQ 'skip.security.ContainedDBSQLAuth').Value
268+
269+
#if ($version -lt 13 ) { $skip = $true }
270+
271+
Context "Testing contained database to see if sql authenticated users exist on <_.Name>" {
272+
It "Database <_.Name> should have no sql authenticated users on <_.SqlInstance>" -Skip:$skip -ForEach $psitem.Databases.Where{ if ($Database) { $_.Name -in $Database -and $_.ContainmentType -ne "NONE" } else { $psitem.ConfigValues.contdbsqlauthexclude -notcontains $psitem.Name -and $_.ContainmentType -ne "NONE" } } {
273+
$psitem.ContainedDbSqlAuthUsers | Should -Be 0 -Because "We expect there to be no sql authenticated users in contained database."
274+
}
275+
}
276+
}

0 commit comments

Comments
 (0)