diff --git a/containers/JessAndBeard.psm1 b/containers/JessAndBeard.psm1 index c21d3d1e..c2b6f2a4 100644 --- a/containers/JessAndBeard.psm1 +++ b/containers/JessAndBeard.psm1 @@ -2326,6 +2326,13 @@ The Tags are the same" FailedChange = -12 # + or - the number of tests failed for v5 SkippedChange = 0 # + or - the number of tests skipped for v5 } + @{ + Name = 'LinkedServerConnection' + RunChange = -3 # + or - the number of tests for v5 + PassedChange = -3 # + or - the number of tests passed for v5 + FailedChange = 0 # + or - the number of tests failed for v5 + SkippedChange = 0 # + or - the number of tests skipped for v5 + } ) $runchange = 0 $passedchange = 0 diff --git a/developing/Robs-Instance.ps1 b/developing/Robs-Instance.ps1 index a6e4d1a1..6c4e7f09 100644 --- a/developing/Robs-Instance.ps1 +++ b/developing/Robs-Instance.ps1 @@ -1,26 +1,26 @@ -$Checks = 'ErrorLogCount','TraceFlagsNotExpected','TraceFlagsExpected', 'XESessionRunningAllowed','XESessionRunning','XESessionRunningAllowed', 'XESessionExists','XESessionStopped','XpCmdShellDisabled','WhoIsActiveInstalled','CLREnabled','TwoDigitYearCutoff','MaxDopInstance','ErrorLogCount','ModelDbGrowth','DefaultBackupCompression','SaExist','SaDisabled','SaRenamed','DefaultFilePath','AdHocDistributedQueriesEnabled','AdHocWorkload', 'DefaultTrace', 'OleAutomationProceduresDisabled', 'CrossDBOwnershipChaining', 'ScanForStartupProceduresDisabled', 'RemoteAccessDisabled', 'SQLMailXPsDisabled', 'DAC', 'OLEAutomation' +$Checks = 'ErrorLogCount', 'TraceFlagsNotExpected', 'TraceFlagsExpected', 'XESessionRunningAllowed', 'XESessionRunning', 'XESessionRunningAllowed', 'XESessionExists', 'XESessionStopped', 'XpCmdShellDisabled', 'WhoIsActiveInstalled', 'CLREnabled', 'TwoDigitYearCutoff', 'MaxDopInstance', 'ErrorLogCount', 'ModelDbGrowth', 'DefaultBackupCompression', 'SaExist', 'SaDisabled', 'SaRenamed', 'DefaultFilePath', 'AdHocDistributedQueriesEnabled', 'AdHocWorkload', 'DefaultTrace', 'OleAutomationProceduresDisabled', 'CrossDBOwnershipChaining', 'ScanForStartupProceduresDisabled', 'RemoteAccessDisabled', 'SQLMailXPsDisabled', 'DAC', 'OLEAutomation' -$Checks = 'XESessionRunningAllowed','XESessionRunning','XESessionRunningAllowed','XESessionExists','XESessionStopped','XpCmdShellDisabled' -$Checks = 'TraceFlagsNotExpected','TraceFlagsExpected' +$Checks = 'XESessionRunningAllowed', 'XESessionRunning', 'XESessionRunningAllowed', 'XESessionExists', 'XESessionStopped', 'XpCmdShellDisabled' +$Checks = 'TraceFlagsNotExpected', 'TraceFlagsExpected' Invoke-PerfAndValidateCheck -Checks $Checks Invoke-PerfAndValidateCheck -Checks $Checks -PerfDetail - +$containers = $SQLInstances = $dbachecks1, $dbachecks2, $dbachecks3 = 'dbachecks1', 'dbachecks2', 'dbachecks3' $password = ConvertTo-SecureString "dbatools.IO" -AsPlainText -Force $cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "sqladmin", $password $show = 'All' $v4code = Invoke-DbcCheck -SqlInstance $Sqlinstances -SqlCredential $cred -Check $Checks -legacy $true -Show $show -PassThru # Run v5 checks -$v5code = Invoke-DbcCheck -SqlInstance $Sqlinstances -SqlCredential $cred -Check $Checks -legacy $false -Show $show -PassThru -Verbose +$v5code = Invoke-DbcCheck -SqlInstance $Sqlinstances -SqlCredential $cred -Check $Checks -legacy $false -Show $show -PassThru -Verbose -Set-DbcConfig -Name policy.xevent.requiredrunningsession -Value system_health -Set-DbcConfig -Name policy.xevent.requiredrunningsession -Value system_health ,AlwaysOn_health -Set-DbcConfig -Name policy.xevent.requiredrunningsession -Value system_health ,AlwaysOn_health,QuickSessionStandard +Set-DbcConfig -Name policy.xevent.requiredrunningsession -Value system_health +Set-DbcConfig -Name policy.xevent.requiredrunningsession -Value system_health , AlwaysOn_health +Set-DbcConfig -Name policy.xevent.requiredrunningsession -Value system_health , AlwaysOn_health, QuickSessionStandard -Set-DbcConfig -Name policy.xevent.validrunningsession -Value system_health ,AlwaysOn_health +Set-DbcConfig -Name policy.xevent.validrunningsession -Value system_health , AlwaysOn_health Set-DbcConfig -Name policy.xevent.validrunningsession -Value AlwaysOn_health $traci = Trace-Script -ScriptBlock { -$v5code = Invoke-DbcCheck -SqlInstance $Sqlinstances -SqlCredential $cred -Check $Checks -legacy $false -Show $show -PassThru + $v5code = Invoke-DbcCheck -SqlInstance $Sqlinstances -SqlCredential $cred -Check $Checks -legacy $false -Show $show -PassThru } \ No newline at end of file diff --git a/readme.md b/readme.md index 13050b00..eb904642 100644 --- a/readme.md +++ b/readme.md @@ -1,8 +1,6 @@ # dbachecks - - - + [![.github/workflows/deploy-module.yml](https://github.com/dataplat/dbachecks/actions/workflows/deploy-module.yml/badge.svg?branch=main)](https://github.com/dataplat/dbachecks/actions/workflows/deploy-module.yml) [![GitHub release badge](https://badgen.net/github/release/dataplat/dbachecks/stable?label=latest_release)](https://github.com/dataplat/dbachecks/releases/latest) diff --git a/source/checks/Instancev5.Tests.ps1 b/source/checks/Instancev5.Tests.ps1 index c87f6fa0..5fc02f1e 100644 --- a/source/checks/Instancev5.Tests.ps1 +++ b/source/checks/Instancev5.Tests.ps1 @@ -391,6 +391,25 @@ Describe "Max Memory" -Tag MaxMemory, High, Instance -ForEach $InstancesToTest { } } +Describe "Orphaned Files" -Tag OrphanedFile, Low, Instance -ForEach $InstancesToTest { + $skip = ($__dbcconfig | Where-Object { $_.Name -eq 'skip.instance.orphanedfile' }).Value + Context "Testing Orphaned Files on <_.Name>" { + It "should not have orphaned files on <_.Name>" -Skip:$skip { + $Psitem.OrphanedFile.FileCount | Should -Be 0 -Because 'You dont want any orphaned files - Use Find-DbaOrphanedFile to locate them' + } + } +} + +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 diff --git a/source/internal/configurations/configuration.ps1 b/source/internal/configurations/configuration.ps1 index fc80ec0f..37cba2a9 100644 --- a/source/internal/configurations/configuration.ps1 +++ b/source/internal/configurations/configuration.ps1 @@ -283,6 +283,8 @@ Set-PSFConfig -Module dbachecks -Name skip.instance.BackupPathAccess -Validation Set-PSFConfig -Module dbachecks -Name skip.instance.networklatency -Validation bool -Value $false -Initialize -Description "Skip the check for network latency" 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" diff --git a/source/internal/functions/NewGet-AllInstanceInfo.ps1 b/source/internal/functions/NewGet-AllInstanceInfo.ps1 index 42a092a9..c5649399 100644 --- a/source/internal/functions/NewGet-AllInstanceInfo.ps1 +++ b/source/internal/functions/NewGet-AllInstanceInfo.ps1 @@ -341,8 +341,8 @@ function NewGet-AllInstanceInfo { $totalMemory = $totalMemory + 1 } $MaxMemory = [PSCustomObject]@{ - MaxValue = $totalMemory - RecommendedValue = $Instance.Configuration.MaxServerMemory.ConfigValue + 379 + MaxValue = $Instance.Configuration.MaxServerMemory.ConfigValue + 379 + RecommendedValue = $totalMemory # because we added 379 before and I have zero idea why } } else { @@ -354,6 +354,16 @@ function NewGet-AllInstanceInfo { } } + OrphanedFile { + $FileCount = @(Find-DbaOrphanedFile -SqlInstance $Instance).Count + } + + ServerNameMatch { + $ServerNameMatchconfiguredServerName = $Instance.Query("SELECT @@servername AS ServerName").ServerName + $ServerNameMatchnetName = $Instance.NetName + $ServerNameMatchrenamerequired = $ServerNameMatchnetName -ne $ServerNameMatchconfiguredServerName + } + Default { } } @@ -444,6 +454,14 @@ function NewGet-AllInstanceInfo { } } MaxMemory = $MaxMemory + OrphanedFile = [pscustomobject]@{ + FileCount = $FileCount + } + ServerNameMatch = [pscustomobject]@{ + configuredServerName = $ServerNameMatchconfiguredServerName + netName = $ServerNameMatchnetName + renamerequired = $ServerNameMatchrenamerequired + } # TempDbConfig = [PSCustomObject]@{ # TF118EnabledCurrent = $tempDBTest[0].CurrentSetting # TF118EnabledRecommended = $tempDBTest[0].Recommended