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/source/checks/Instancev5.Tests.ps1 b/source/checks/Instancev5.Tests.ps1 index c87f6fa0..b03b5c5f 100644 --- a/source/checks/Instancev5.Tests.ps1 +++ b/source/checks/Instancev5.Tests.ps1 @@ -391,6 +391,14 @@ 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 "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..722abd4c 100644 --- a/source/internal/configurations/configuration.ps1 +++ b/source/internal/configurations/configuration.ps1 @@ -283,6 +283,7 @@ 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" diff --git a/source/internal/functions/NewGet-AllInstanceInfo.ps1 b/source/internal/functions/NewGet-AllInstanceInfo.ps1 index 42a092a9..15a5ccfe 100644 --- a/source/internal/functions/NewGet-AllInstanceInfo.ps1 +++ b/source/internal/functions/NewGet-AllInstanceInfo.ps1 @@ -354,6 +354,10 @@ function NewGet-AllInstanceInfo { } } + OrphanedFile { + $FileCount = @(Find-DbaOrphanedFile -SqlInstance $Instance).Count + } + Default { } } @@ -444,6 +448,9 @@ function NewGet-AllInstanceInfo { } } MaxMemory = $MaxMemory + OrphanedFile = [pscustomobject]@{ + FileCount = $FileCount + } # TempDbConfig = [PSCustomObject]@{ # TF118EnabledCurrent = $tempDBTest[0].CurrentSetting # TF118EnabledRecommended = $tempDBTest[0].Recommended