Skip to content

Commit

Permalink
so we can check for hideinstance #882
Browse files Browse the repository at this point in the history
  • Loading branch information
SQLDBAWithABeard committed May 9, 2023
1 parent 74d108a commit 434637d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions developing/Robs-Instance.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ $Checks = 'LinkedServerConnection'
$Checks = 'MaxMemory'
$Checks = 'OrphanedFile'
$Checks = 'MemoryDump'
$Checks = 'HideInstance'

Invoke-PerfAndValidateCheck -Checks $Checks
Invoke-PerfAndValidateCheck -Checks $Checks -PerfDetail
Expand Down
10 changes: 10 additions & 0 deletions source/checks/Instancev5.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,16 @@ Describe "Error Log Count" -Tag ErrorLogCount, CIS, Low, Instance -ForEach $Inst
}
}

Describe "Hide Instance" -Tag HideInstance, Security, CIS, Medium, Instance -ForEach $InstancesToTest {
$skip = ($__dbcconfig | Where-Object { $_.Name -eq 'skip.security.hideinstance' }).Value
Context "Checking the Hide an Instance of SQL Server Database Engine property on <_.Name>" {
It "The Hide an Instance of SQL Server Database Engine property on SQL Server instance <_.Name>" -Skip:$skip {
# We don't make this -BeTrue because the possible results are $true/$false/'Could not connect'
$psitem.HideInstance.Result | Should -Be $true -Because "We expected the hide instance property to be set to $true"
}
}
}

Describe "Instance Connection" -Tag InstanceConnection, Connectivity, High, Instance -ForEach $InstancesToTest {
BeforeAll {
$skipall = ($__dbcconfig | Where-Object { $_.Name -eq 'skip.connection' }).Value
Expand Down
13 changes: 13 additions & 0 deletions source/internal/functions/NewGet-AllInstanceInfo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,18 @@ function NewGet-AllInstanceInfo {
}
}

'HideInstance' {
try {
$HideInstance = [pscustomobject] @{
Result = (Get-DbaHideInstance -SqlInstance $InstanceSMO).HideInstance
}
} catch {
$HideInstance = [pscustomobject] @{
Result = 'We Could not Connect to $Instance'
}
}
}

Default { }
}

Expand Down Expand Up @@ -487,6 +499,7 @@ function NewGet-AllInstanceInfo {
renamerequired = $ServerNameMatchrenamerequired
}
MemoryDump = $Dump
HideInstance = $HideInstance
# TempDbConfig = [PSCustomObject]@{
# TF118EnabledCurrent = $tempDBTest[0].CurrentSetting
# TF118EnabledRecommended = $tempDBTest[0].Recommended
Expand Down

0 comments on commit 434637d

Please sign in to comment.