PowerShell DbaTools Pass Hashtable to Invoke-DbaQuery

264 views Asked by At

I am trying to pass a Hashtable called $SqlInstanceParams to the Invoke-DbaQuery dbatools command:

Invoke-DbaQuery -SqlInstance "X" -Database "X" -Query "Set-SQLInstance" -SqlParameters $SqlInstanceParams -CommandType StoredProcedure

Displaying the hashtable variable I have populated, all looks fine but when the query executes I got this error:

No mapping exists from object type System.Version to a known managed
provider native type.

Do I need to somehow convert this hashtable or list each parameter out individually like so instead of just passing the hashtable variable:

$SqlInstanceParams = @{IsClustered = $SqlInstanceParams["IsClustered"]; 
                      ServerName = $SqlInstanceParams["ServerName"] etc}


 
1

There are 1 answers

0
SteveH On

This turned out to be a data mapping issue between the Hashtable values and the SQL table.