Skip to content

Commit

Permalink
Merge pull request #805 from Ant-Green/DocFix
Browse files Browse the repository at this point in the history
Doc fix
  • Loading branch information
SQLDBAWithABeard committed Nov 23, 2020
2 parents 5deac81 + bd2c848 commit a8ad3ba
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 15 deletions.
9 changes: 5 additions & 4 deletions checks/Database.Tests.ps1
Expand Up @@ -285,7 +285,8 @@ $ExcludedDatabases += $ExcludeDatabase
}

Describe "Duplicate Index" -Tags DuplicateIndex, $filename {
$Excludeddbs = $ExcludedDatabases + 'msdb'
$Excludeddbs = Get-DbcConfigValue policy.database.duplicateindexexcludedb
$Excludeddbs += $ExcludedDatabases
if ($NotContactable -contains $psitem) {
Context "Testing duplicate indexes on $psitem" {
It "Can't Connect to $Psitem" {
Expand Down Expand Up @@ -1041,9 +1042,9 @@ $ExcludedDatabases += $ExcludeDatabase
else {
$instance = $Psitem
Context "Testing Guest user has CONNECT permission on $psitem" {
@($InstanceSMO.Databases.Where{ $(if ($Database) { $PsItem.Name -in $Database }else { $ExcludedDatabases -notcontains $PsItem.Name }) }).Foreach{
It "Database Guest user should return no CONNECT permissions in $($psitem.Name) on $Instance" -Skip:$skip {
Assert-GuestUserConnect -Instance $instance -Database $($psitem.Name)
@(Get-Database -Instance $Instance -Requiredinfo Name -Exclusions NotAccessible -Database $Database -ExcludedDbs $ExcludedDatabases).ForEach{
It "Database Guest user should return no CONNECT permissions in $psitem on $Instance" -Skip:$skip {
Assert-GuestUserConnect -Instance $instance -Database $psitem
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion checks/Instance.Tests.ps1
Expand Up @@ -796,6 +796,7 @@ $Tags = Get-CheckInformation -Check $Check -Group Instance -AllChecks $AllChecks
}
Describe "Trace Flags Not Expected" -Tags TraceFlagsNotExpected, TraceFlag, Medium, $filename {
$NotExpectedTraceFlags = Get-DbcConfigValue policy.traceflags.notexpected
$ExpectedTraceFlags = Get-DbcConfigValue policy.traceflags.expected
if ($NotContactable -contains $psitem) {
Context "Testing Not Expected Trace Flags on $psitem" {
It "Can't Connect to $Psitem" {
Expand All @@ -806,7 +807,7 @@ $Tags = Get-CheckInformation -Check $Check -Group Instance -AllChecks $AllChecks
else {
Context "Testing Not Expected Trace Flags on $psitem" {
It "Expected Trace Flags $NotExpectedTraceFlags to not exist on $psitem" {
Assert-NotTraceFlag -SQLInstance $psitem -NotExpectedTraceFlag $NotExpectedTraceFlags
Assert-NotTraceFlag -SQLInstance $psitem -NotExpectedTraceFlag $NotExpectedTraceFlags -ExpectedTraceFlag $ExpectedTraceFlags
}
}
}
Expand Down
14 changes: 10 additions & 4 deletions docs/index.md
Expand Up @@ -37,15 +37,21 @@ Want to know how our CD process works? Read this [blog post](https://sqldbawitha

## Prerequisites
### Client requirements
* PowerShell 4+ is required.
* PowerShell 5 + is required.
* Automatic installation of the dependent modules will only be provided via the [PowerShell Gallery](https://www.powershellgallery.com).

When you install from the Gallery, it'll auto-install:

* dbatools
* Pester
* PSFramework

You will also need to manually install the Pester module at version 4.10.0, this is due to inconsistencies between dbachecks and Pester v5. If you have Pester v5 installed it is recommended to remove this and use Pester 4.10.0 or force an import of 4.10.0 when running dbachecks

````
Install-Module Pester -SkipPublisherCheck -Force -RequiredVersion 4.10.0
Import-Module Pester -Force -RequiredVersion 4.10.0
````

When you import, it'll auto-import

* dbatools
Expand All @@ -59,8 +65,8 @@ If you have already installed the module and you update it, you may be required
Then you need to

````
Install-Module Pester -SkipPublisherCheck -Force
Import-Module Pester -Force
Install-Module Pester -SkipPublisherCheck -Force -RequiredVersion 4.10.0
Import-Module Pester -Force -RequiredVersion 4.10.0
````

You may need to do the same thing for the PSFramework or dbatools modules also
Expand Down
2 changes: 1 addition & 1 deletion internal/assertions/Database.Assertions.ps1
Expand Up @@ -77,7 +77,7 @@ function Assert-GuestUserConnect {
[string]$Instance,
[string]$Database
)
$guestperms = Get-DbaUserPermission -SqlInstance $Instance -Database $psitem.Name | Where-Object {$_.Grantee -eq "guest" -and $_.Permission -eq "CONNECT"}
$guestperms = Get-DbaUserPermission -SqlInstance $Instance -Database $Database | Where-Object {$_.Grantee -eq "guest" -and $_.Permission -eq "CONNECT"}
$guestperms.Count | Should -Be 0 -Because "We expect the guest user in $Database on $Instance to not have CONNECT permissions"
}

Expand Down
5 changes: 3 additions & 2 deletions internal/assertions/Instance.Assertions.ps1
Expand Up @@ -924,11 +924,12 @@ function Assert-TraceFlag {
function Assert-NotTraceFlag {
Param(
[string]$SQLInstance,
[int[]]$NotExpectedTraceFlag
[int[]]$NotExpectedTraceFlag,
[int[]]$ExpectedTraceFlag
)

if ($null -eq $NotExpectedTraceFlag) {
(Get-DbaTraceFlag -SqlInstance $SQLInstance).TraceFlag | Should -BeNullOrEmpty -Because "We expect that there will be no Trace Flags set on $SQLInstance"
((Get-DbaTraceFlag -SqlInstance $SQLInstance).Where{ $_.TraceFlag -notin $ExpectedTraceFlag} | Select-Object).TraceFlag | Should -BeNullOrEmpty -Because "We expect that there will be no Trace Flags set on $SQLInstance"
}
else {
@($NotExpectedTraceFlag).ForEach{
Expand Down
1 change: 1 addition & 0 deletions internal/configurations/configuration.ps1
Expand Up @@ -150,6 +150,7 @@ Set-PSFConfig -Module dbachecks -Name policy.database.status.excludeoffline -Val
Set-PSFConfig -Module dbachecks -Name policy.database.status.excluderestoring -Value @() -Initialize -Description "Database names that we expect to be restoring"
Set-PSFConfig -Module dbachecks -Name database.querystoreenabled.excludedb -Value @() -Initialize -Description "A List of databases that we do not want to check for Query Store enabled"
Set-PSFConfig -Module dbachecks -Name database.querystoredisabled.excludedb -Value @() -Initialize -Description "A List of databases that we do not want to check for Query Store disabled"
Set-PSFConfig -Module dbachecks -Name policy.database.duplicateindexexcludedb -Value @('msdb','ReportServer','ReportServerTempDB') -Initialize -Description "A List of databases we do not want to check for Duplicate Indexes"

# Policy for Ola Hallengren Maintenance Solution
Set-PSFConfig -Module dbachecks -name policy.ola.installed -Validation bool -Value $true -Initialize -Description "Checks to see if Ola Hallengren solution is installed"
Expand Down
12 changes: 9 additions & 3 deletions readme.md
Expand Up @@ -59,9 +59,15 @@ Want to know how our CD process works? Read this [blog post](https://sqldbawitha
When you install from the Gallery, it'll auto-install:

* dbatools
* Pester
* PSFramework

You will also need to manually install the Pester module at version 4.10.0, this is due to inconsistencies between dbachecks and Pester v5. If you have Pester v5 installed it is recommended to remove this and use Pester 4.10.0 or force an import of 4.10.0 when running dbachecks

````
Install-Module Pester -SkipPublisherCheck -Force -RequiredVersion 4.10.0
Import-Module Pester -Force -RequiredVersion 4.10.0
````

When you import, it'll auto-import

* dbatools
Expand All @@ -75,8 +81,8 @@ If you have already installed the module and you update it, you may be required
Then you need to

````
Install-Module Pester -SkipPublisherCheck -Force
Import-Module Pester -Force
Install-Module Pester -SkipPublisherCheck -Force -RequiredVersion 4.10.0
Import-Module Pester -Force -RequiredVersion 4.10.0
````

You may need to do the same thing for the PSFramework or dbatools modules also
Expand Down

0 comments on commit a8ad3ba

Please sign in to comment.