Skip to content
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

Get-DbaAgBackupHistory - Stop even if no exception is raised #7327

Merged
merged 2 commits into from
May 18, 2021

Conversation

andreasjordan
Copy link
Contributor

Type of Change

  • Bug fix (non-breaking change, fixes # )
  • New feature (non-breaking change, adds functionality, fixes # )
  • Breaking change (effects multiple commands or functionality, fixes # )
  • Ran manual Pester test and has passed (`.\tests\manual.pester.ps1)
  • Adding code coverage to existing functionality
  • Pester test is included
  • If new file reference added for test, has is been added to github.com/sqlcollaborative/appveyor-lab ?
  • Nunit test is included
  • Documentation
  • Build system

Purpose

When no exception is raised by Stop-Function, then the end block continues and tries to connect to an empty list of instances.

Approach

Add a return after Stop-Function

@andreasjordan
Copy link
Contributor Author

Just found it while helping a user on slack.

Here are the messages before the fix:

WARNING: [23:59:44][Get-DbaAgBackupHistory] Error occurred while establishing connection to MyNode-1 | Access is denied
WARNING: [23:59:59][Get-DbaAgBackupHistory] Error occurred while establishing connection to MyNode-2 | Access is denied
WARNING: [23:59:59][Get-DbaAgBackupHistory] No instances with availability group named 'XXXXX' found, so finishing without results.
Get-DbaDbBackupHistory : Cannot bind argument to parameter 'SqlInstance' because it is an empty array.
At C:\Program Files\WindowsPowerShell\Modules\dbatools\1.0.142\functions\Get-DbaAgBackupHistory.ps1:195 char:58
+ ...  $AgResults = Get-DbaDbBackupHistory -SqlInstance $serverList @PSBoun ...
+                                                       ~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-DbaDbBackupHistory], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyArrayNotAllowed,Get-DbaDbBackupHistory

@andreasjordan
Copy link
Contributor Author

Failed test not related to command.

@potatoqualitee
Copy link
Member

Makes sense, looks good! Thanks so much.

@potatoqualitee potatoqualitee merged commit 800b7ff into development May 18, 2021
@potatoqualitee potatoqualitee deleted the GetDbaAgBackupHistory_FixNoInstances branch May 18, 2021 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants