New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Invoke-DbcFailureResponse #405

potatoqualitee opened this Issue Mar 19, 2018 · 3 comments


None yet
4 participants
Copy link

potatoqualitee commented Mar 19, 2018

Invoke-DbcCheck -SqlInstance sql2017 -Check LastGoodCheckDb -PassThru -EnableFix | Invoke-DbcFailureResponse

The -EnableFix will add two or three properties to output (which makes it slower) hence the requirement of a new switch. Server which is the SMO connected object $server then FixType and FixTarget

foreach ($failure in ($InputObject.TestResult | Where-Object Result -eq Failed)) {
    $target = $failure.FixTarget
    $server = $failure.Server
    switch ($failure.Describe) {
        "Last Good DBCC CHECKDB" {
            $server.Query("DBCC CHECKDB $target")
        "Recovery Model" {
            $recoverymodel = Get-DbcConfigValue -Name policy.recoverymodel.type
            Set-DbaDbRecoveryModel -SqlInstance $server -Database $target -RecoveryModel $recoverymodel 

We can add -Confirm:$false to all of them or let the user decide perhaps with a config. I'm proposing this but don't currently have plans to program it so if it's agreed on, anyone who wants can grab it. Just wanted to throw it out there as a potential solution for a question we regularly get.

FixType would be something like Database or Instance. Not sure if it'd be needed but seems like it'd have the potential to be useful.


This comment has been minimized.

Copy link

shaneis commented Mar 28, 2018

Ooooh are we talking something like

"Last Full Backup" {
    $Backup = Get-DbcConfigValue -Name policy.backup.maxfulldays
    Backup-DbaDatabase ...



This comment has been minimized.

Copy link

potatoqualitee commented Mar 29, 2018

Yep! So whatever we would do to fix it but instead, PowerShell fixes it.


This comment has been minimized.

Copy link

wsmelton commented Mar 29, 2018

So adding a remediation button? (aka gold disk lock it all down 🎉 🎈 👶 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment