Skip to content

Commit

Permalink
so that the instance checks dont break Add Pester V5 Instance Level C…
Browse files Browse the repository at this point in the history
…hecks #882
  • Loading branch information
SQLDBAWithABeard committed Aug 19, 2023
1 parent 6d94262 commit aa3b2f5
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion source/internal/functions/NewGet-AllInstanceInfo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -507,9 +507,42 @@ function NewGet-AllInstanceInfo {
}

'SqlEngineServiceAccount' {
$EngineAccounts = Get-DbaService -ComputerName $psitem -Type Engine -ErrorAction SilentlyContinue
$starttype = ($__dbcconfig | Where-Object { $_.Name -eq 'policy.instance.sqlenginestart' }).Value
$state = ($__dbcconfig | Where-Object { $_.Name -eq 'policy.instance.sqlenginestate' }).Value
try {
$EngineAccounts = Get-DbaService -ComputerName $psitem -Type Engine -ErrorAction Stop

} catch [System.Exception] {
if ($_.Exception.Message -like '*No services found in relevant namespaces*') {
$EngineAccounts = [PSCustomObject]@{
InstanceName = $Instance.Name
State = 'unknown'
ExpectedState = $state
StartType = 'unknown'
ExpectedStartType = $starttype
because = 'Some sort of failure - No services found in relevant namespaces'
}
} else {
$EngineAccounts = [PSCustomObject]@{
InstanceName = $Instance.Name
State = 'unknown'
ExpectedState = $state
StartType = 'unknown'
ExpectedStartType = $starttype
because = 'Some sort of failure'
}
}
} catch {
$EngineAccounts = [PSCustomObject]@{
InstanceName = $Instance.Name
State = 'unknown'
ExpectedState = $state
StartType = 'unknown'
ExpectedStartType = $starttype
because = 'We Could not Connect to $Instance $ComputerName , $InstanceName from catch'
}
}

if ($Instance.IsClustered) {
$starttype = 'Manual'
$because = 'This is a clustered instance and Clustered Instances required that the SQL engine service is set to manual'
Expand Down

0 comments on commit aa3b2f5

Please sign in to comment.