Skip to content

Commit

Permalink
server name match should be checked #882
Browse files Browse the repository at this point in the history
  • Loading branch information
SQLDBAWithABeard committed Mar 30, 2023
1 parent 18319ae commit c2bc14a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
11 changes: 11 additions & 0 deletions source/checks/Instancev5.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,17 @@ Describe "Orphaned Files" -Tag OrphanedFile, Low, Instance -ForEach $InstancesTo
}
}
}

Describe "SQL and Windows names match" -Tag ServerNameMatch, Medium, Instance -ForEach $InstancesToTest {
$skip = ($__dbcconfig | Where-Object { $_.Name -eq 'skip.instance.servernamematch' }).Value
Context "Testing SQL and Windows names match on <_.Name>" {
It "should have matching names on <_.Name>" -Skip:$skip {
$Psitem.ServerNameMatch.renamerequired | Should -BeFalse -Because "SQL and Windows names should match but configured name $($Psitem.ServerNameMatch.configuredServerName) does not match $($Psitem.ServerNameMatch.netName)"
}
}
}


<#
Describe "TempDB Configuration" -Tags TempDbConfiguration, Medium, Instance -ForEach $InstancesToTest {
Context "Testing TempDB Configuration on $psitem" -Skip:(($__dbcconfig | Where-Object { $_.Name
Expand Down
1 change: 1 addition & 0 deletions source/internal/configurations/configuration.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ Set-PSFConfig -Module dbachecks -Name skip.instance.networklatency -Validation b
Set-PSFConfig -Module dbachecks -Name skip.instance.linkedserverconnection -Validation bool -Value $false -Initialize -Description "Skip the check for linked server connection"
Set-PSFConfig -Module dbachecks -Name skip.instance.maxmemory -Validation bool -Value $false -Initialize -Description "Skip the check for max memory"
Set-PSFConfig -Module dbachecks -Name skip.instance.orphanedfile -Validation bool -Value $false -Initialize -Description "Skip the check for orphaned file"
Set-PSFConfig -Module dbachecks -Name skip.instance.servernamematch -Validation bool -Value $false -Initialize -Description "Skip the check for server name match"



Expand Down
11 changes: 11 additions & 0 deletions source/internal/functions/NewGet-AllInstanceInfo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,12 @@ function NewGet-AllInstanceInfo {
$FileCount = @(Find-DbaOrphanedFile -SqlInstance $Instance).Count
}

ServerNameMatch {
$ServerNameMatchconfiguredServerName = $Instance.Query("SELECT @@servername AS ServerName").ServerName
$ServerNameMatchnetName = $Instance.NetName
$ServerNameMatchrenamerequired = $ServerNameMatchnetName -ne $ServerNameMatchconfiguredServerName
}

Default { }
}

Expand Down Expand Up @@ -451,6 +457,11 @@ function NewGet-AllInstanceInfo {
OrphanedFile = [pscustomobject]@{
FileCount = $FileCount
}
ServerNameMatch = [pscustomobject]@{
configuredServerName = $ServerNameMatchconfiguredServerName
netName = $ServerNameMatchnetName
renamerequired = $ServerNameMatchrenamerequired
}
# TempDbConfig = [PSCustomObject]@{
# TF118EnabledCurrent = $tempDBTest[0].CurrentSetting
# TF118EnabledRecommended = $tempDBTest[0].Recommended
Expand Down

0 comments on commit c2bc14a

Please sign in to comment.