dbatools icon indicating copy to clipboard operation
dbatools copied to clipboard

Get-DbaDependency Invalid type conversion error

Open Adam-Wenger opened this issue 8 years ago • 2 comments

Before submitting a bug report:

  • [X ] Ensure you are able to reproduce it on the latest released version (we release often)
  • [X ] Verified this bug is not already reported in an issue
  • [X ] Verified errors are not related to permissions
  • [X ] Can reproduce in a clean PowerShell session (clean = powershell -NoProfile)

Steps to Reproduce

$testTable = Get-DbaDbTable -SqlInstance $devInstance -Database Warehouse -Table 'm.Config';
$testTable | Get-DbaDependency;

Expected Behavior

Type conversion error does not happen.

Actual Behavior

image

Get-DbaDependency takes in EnableException as a Switch, then passes it to: Write-Message and Get-DependencyTree, both of which have the variable typed as a bool

The error indicates the issue with Write-Message, but may happen again with Get-DependencyTree.

Environmental data

Powershell 5.1

Adam-Wenger avatar Dec 05 '18 15:12 Adam-Wenger

I see the same issue too today, but now in version 0.9.722 it also mentions MessageLevel, and reports the EnableException error twice:

Write-Message : Cannot convert 'System.Management.Automation.SwitchParameter' to the type 'System.Boolean' required by parameter 'EnableException'.
At line:36184 char:44
+             Write-Message -EnableException $EnableException -Level Ve ...
+                                            ~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Write-Message], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgument,Sqlcollaborative.Dbatools.Commands.WriteMessageCommand

Write-Message : Cannot bind parameter 'Level'. Cannot convert value "Host" to type "Sqlcollaborative.Dbatools.Message.MessageLevel". Error: "Unable to match the identifier name Host to a valid
enumerator name. Specify one of the following enumerator names and try again:
Critical, Important, Output, Significant, VeryVerbose, Verbose, SomewhatVerbose, System, Debug, InternalComment, Warning"
At line:36205 char:87
+ ... -Message -Message "No dependencies detected for $($Item)" -Level Host
+                                                                      ~~~~
    + CategoryInfo          : InvalidArgument: (:) [Write-Message], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Sqlcollaborative.Dbatools.Commands.WriteMessageCommand

Write-Message : Cannot convert 'System.Management.Automation.SwitchParameter' to the type 'System.Boolean' required by parameter 'EnableException'.
At line:36184 char:44
+             Write-Message -EnableException $EnableException -Level Ve ...
+                                            ~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Write-Message], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgument,Sqlcollaborative.Dbatools.Commands.WriteMessageCommand

wsuhoey avatar Dec 19 '18 19:12 wsuhoey

This issue has been automatically marked as stale because it has not had recent activity. If you would like this issue to remain open:

  • Verify that you can still reproduce the issue in the latest version of dbatools
  • Comment that the issue is still reproducible and include:
    • What version of dbatools you reproduced the issue on
    • What OS and version you reproduced the issue on
    • What steps you followed to reproduce the issue

stale[bot] avatar Feb 17 '19 20:02 stale[bot]