Inconsistent output of Get-DbaDatabaseState function #648

ie-zero opened this Issue Feb 5, 2017 · 0 comments


None yet

2 participants

ie-zero commented Feb 5, 2017 edited

Is this a feature OR bug:

Bug - Impact Low

Get-DbaDatabaseState function exhibits inconsistent behavior based on the order the input parameter values are passed.

System Details

  • Operating system name and version: Windows 7
  • Output from $PSVersionTable:
Name Value
PSVersion 5.0.10586.117
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.10586.117
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
  • Output of dbatools version:

  • SQL Server version for source/target
    SQL Express (I do not believe it is relevant though)

Steps to Reproduce

Let assume the following scenario ABC\InstanceA is a valid SQL Server instance and DEF is not.

Execution 1, the server appearing first on the -SqlInstance list, i.e. ABC\InstanceA, is accessible

Get-DbaDatabaseState -SqlInstance 'ABC\InstanceA', DEF -Exclude ICalData

SqlInstance  : ABC\InstanceA
InstanceName : InstanceA
ComputerName : ABC
DatabaseName : ICalData
RW           : READ_WRITE
Status       : ONLINE
Access       : MULTI_USER

WARNING: Can't connect to DEF

Execution 2, the server appearing first on the -SqlInstance list, i.e. DEF, is not accessible

Get-DbaDatabaseState -SqlInstance DEF, 'ABC\InstanceA' -Exclude ICalData

Get-DbaDatabaseState : A parameter cannot be found that matches parameter name 'Exclude'.
At line:1 char:60
+ ... DatabaseState -SqlInstance DEF, 'ABC\InstanceA' -Exclude ICalDat ...
+                                                         ~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-DbaDatabaseState], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Get-DbaDatabaseState


The most possible cause of this behavior is the way we handle dynamically the -Databases and -Exclude input parameters

@SirCaptainMitch SirCaptainMitch added the bug label Feb 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment