You cannot use a query in a variable. All variables do is substitute the database value pointed to in place of the variable. It is that simple.
The problem is that the DB value you are looking for is a one to many relationship in the database. The computer has lots of files so you cannot use them in a variable. You can only use DB values that have a one to one relationship in the DB like a computer name. The computer only has one computer name.
I managed to sort this using the MBSDK. Initially i wanted to grab the Database value and use it as a variable in Provisioning directly but this way I can create the variable within the Powershell code and grab the data that way.
$LDWebService = (New-WebServiceProxy -Uri http://CORESERVER/MBSDKService/MsgSDK.asmx?WSDL -Credential $Cred)
$QueryName = "QUERYNAME"
$Result = $LDWebService.RunQuery($QueryName)
foreach ($Row in $Result.Tables.Rows)
write-host "value is : $($Row) $($Row)"
This gave me the values for Row 1 and Row 5
Row 1 was the Device Name and Row 5 was the Managed Software File Path for the file in question.
example of Data Returned.
value is : COMPUTERNAME C:\ORACLE\ORA11G\NETWORK\ADMIN\LDAP.ORA
So i found all machines with the file in question and also the path of that file as it is located in many different places.