diff --git a/source/checks/Instancev5.Tests.ps1 b/source/checks/Instancev5.Tests.ps1 index 4a6889f0..fb298938 100644 --- a/source/checks/Instancev5.Tests.ps1 +++ b/source/checks/Instancev5.Tests.ps1 @@ -34,7 +34,29 @@ BeforeDiscovery { Set-PSFConfig -Module dbachecks -Name global.notcontactable -Value $NotContactable # Get-DbcConfig is expensive so we call it once $__dbcconfig = Get-DbcConfig + $notcontactable = (Get-PSFConfig -Module dbachecks -Name global.notcontactable).Value + $Checks = Get-DbcCheck + $TestsNoGoBrrr = foreach ($Not in $notcontactable) { + foreach ($tag in $tags) { + [PSCustomObject]@{ + Name = $Not + Tag = $tag + } + } + } +} + +BeforeAll { + } +Describe "<_.Tag> failed on <_.Name>" -Tag FailedConnections -ForEach $TestsNoGoBrrr { + Context "Checking <_.Tag> on <_.Name>" { + It "The instance <_.Name> is not connectable" -Skip:$skip { + $false | Should -BeTrue -Because "This instance is not connectable" + } + } +} + # Ordered alphabetically by unique tag please Describe "Ad Hoc Distributed Queries" -Tag AdHocDistributedQueriesEnabled, security, CIS, Medium, Instance -ForEach $InstancesToTest { diff --git a/source/functions/Invoke-DbcCheck.ps1 b/source/functions/Invoke-DbcCheck.ps1 index de25dae8..a79d8a52 100644 --- a/source/functions/Invoke-DbcCheck.ps1 +++ b/source/functions/Invoke-DbcCheck.ps1 @@ -286,6 +286,7 @@ function Invoke-DbcCheck { } } process { + if ($legacy) { try { Write-PSFMessage 'Running in legacy mode, we need Version 4' @@ -365,7 +366,7 @@ function Invoke-DbcCheck { # cast from empty hashtable to get default $configuration = New-PesterConfiguration $configuration.Output.Verbosity = $NewShow - $configuration.Filter.Tag = $check + $configuration.Filter.Tag = $check + 'FailedConnections' $configuration.Filter.ExcludeTag = $ExcludeCheck if ($PassThru) { $configuration.Run.PassThru = $true diff --git a/source/internal/functions/Invoke-DbcCheckv5.ps1 b/source/internal/functions/Invoke-DbcCheckv5.ps1 index 84ff7772..6101dbe4 100644 --- a/source/internal/functions/Invoke-DbcCheckv5.ps1 +++ b/source/internal/functions/Invoke-DbcCheckv5.ps1 @@ -46,7 +46,7 @@ function Invoke-DbcCheckv5 { $name = "Config" + (($name.Split(".") | ForEach-Object { $_.SubString(0, 1).ToUpper() + $_.SubString(1) }) -join '') $ParamAttrib = New-Object System.Management.Automation.ParameterAttribute $ParamAttrib.ParameterSetName = '__AllParameterSets' - $AttribColl = New-Object System.Collections.ObjectModel.Collection[System.Attribute] + $AttribColl = New-Object System.Collections.ObjectModel.Collection[System.Attribute] $AttribColl.Add($ParamAttrib) $RuntimeParam = New-Object System.Management.Automation.RuntimeDefinedParameter($name, [object], $AttribColl) @@ -159,8 +159,8 @@ function Invoke-DbcCheckv5 { Write-PSFMessage -Message "SqlInstance is $SqlInstance" -Level Verbose # Because we have all these bound params :-( $null = $PSBoundParameters.Remove('configuration') - Invoke-Pester -Configuration $configuration + Pop-Location } } diff --git a/source/internal/functions/NewGet-AllInstanceInfo.ps1 b/source/internal/functions/NewGet-AllInstanceInfo.ps1 index b1a380ac..4b85b0a5 100644 --- a/source/internal/functions/NewGet-AllInstanceInfo.ps1 +++ b/source/internal/functions/NewGet-AllInstanceInfo.ps1 @@ -419,16 +419,16 @@ function NewGet-AllInstanceInfo { { 'PublicRolePermissions' -or 'PublicPermission' } { #This needs to be done in query just in case the account had already been renamed $query = " - SELECT Count(*) AS [RowCount] - FROM master.sys.server_permissions - WHERE (grantee_principal_id = SUSER_SID(N'public') and state_desc LIKE 'GRANT%') - AND NOT (state_desc = 'GRANT' and [permission_name] = 'VIEW ANY DATABASE' and class_desc = 'SERVER') - AND NOT (state_desc = 'GRANT' and [permission_name] = 'CONNECT' and class_desc = 'ENDPOINT' and major_id = 2) - AND NOT (state_desc = 'GRANT' and [permission_name] = 'CONNECT' and class_desc = 'ENDPOINT' and major_id = 3) - AND NOT (state_desc = 'GRANT' and [permission_name] = 'CONNECT' and class_desc = 'ENDPOINT' and major_id = 4) - AND NOT (state_desc = 'GRANT' and [permission_name] = 'CONNECT' and class_desc = 'ENDPOINT' and major_id = 5); + SELECT Count(*) AS [RowCount] + FROM master.sys.server_permissions + WHERE (grantee_principal_id = SUSER_SID(N'public') and state_desc LIKE 'GRANT%') + AND NOT (state_desc = 'GRANT' and [permission_name] = 'VIEW ANY DATABASE' and class_desc = 'SERVER') + AND NOT (state_desc = 'GRANT' and [permission_name] = 'CONNECT' and class_desc = 'ENDPOINT' and major_id = 2) + AND NOT (state_desc = 'GRANT' and [permission_name] = 'CONNECT' and class_desc = 'ENDPOINT' and major_id = 3) + AND NOT (state_desc = 'GRANT' and [permission_name] = 'CONNECT' and class_desc = 'ENDPOINT' and major_id = 4) + AND NOT (state_desc = 'GRANT' and [permission_name] = 'CONNECT' and class_desc = 'ENDPOINT' and major_id = 5); " - $PublicRolePermsCount = $srv.Query($query).RowCount + $PublicRolePermsCount = $Instance.Query($query).RowCount } 'SuspectPageLimit' {