Categories
Database Development

Passing in multiple instances into the dbatools command GET-DBADBFILE

I am attempting to gather all of the dbfile information on all of our sql instances in one of our environments. It is a fairly large environment and would be tedious to perform one instance at a time. I thought there would be an easy way to do this with Powershell but I seem to be running into a roadblock.

I have a list of instances stored in a table/view [vSQLInstances]. If I pass those values into a variable and then use that variable as the SQLInstance parameter, I get an error.

Script I’m using…

$sqlinstance = Invoke-DbaQuery -SqlInstance dbasql01\sql2019 -Database DBAEstate -Query "select sqlinstance from vSQLInstance;"

Get-DbadbFile -SqlInstance $sqlinstance | Select-Object sqlinstance, database, logicalname, size 

The error I receive:

Get-DbaDbFile : Cannot process argument transformation on parameter 'SqlInstance'. Cannot convert value 
"@{sqlinstance=PRODSQLD\D}" to type "Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter". Error: "Failed to interpret 
input as Instance: @{sqlinstance=PRODSQLD\D}"
At line:11 char:28
+ Get-DbaDbFile -SqlInstance $instancelist
+                            ~~~~~~~~~~~~~
+ CategoryInfo          : InvalidData: (:) [Get-DbaDbFile], ParameterBindingArgumentTransformationException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Get-DbaDbFile

Leave a Reply

Your email address will not be published. Required fields are marked *