This is driving me crazy, how do I query the API for a list of computer IDs based on the first 4 of the computer name? I have tried so many different combinations over the last 4 hours and can not figure this out. Seems like it should be fairly straight forward. Please help!
The above query returns a list of random numbers a sample of which is below. A sample computer ID that should be returned is 1822287 so none of the below numbers would correspond to what should be returned.
At first glance I don’t see a problem with your query. To troubleshoot I’d probably start by also returning the names of the computers that are being retrieved to see whether we can discern a pattern
(ids of it, names of it) of bes computers whose (name of it as string as uppercase starts with ‘QA00’)
Also check to be sure that your API credential has management rights to the computer, and that the computer properties in the console correctly show you as an operator. The client evaluates the admin rights as an action, so if this client is failing to gather or report then your api credential may not be able to query that particular machine.
I just tried with different admin credentials that should have rights to everything in BigFix… Here is the command and the complete output from it. I don’t get it… At the bottom I included the RawContent method which shows there is an error for invalid character, but unsure where.
$computer = Invoke-WebRequest -Credential $creds -Uri "https://bigfix.spencerstuart.com:52311/api/query?relevance=(ids of it, names of it) of bes computers whose (name of it as string as uppercase starts with "QA00")"
(Note that before each " surrounding QA00 should be a ` backtick)
I have tried the command SLB recommended, with the ` before the "s and with %20 encoding and it just returns the same garbage listed above… I am at a loss… Has anyone else run into this? This seems like it should be fairly straight forward.
I’m not familiar enough with PowerShell at the moment, but this seems to be an artifact of the .Content method to read the $computer variable. The same happens to me with any query to /api/query. .RawContent worked better. And if you add &output=json as a query parameter, that might avoid the XML parsing error you reference above.
That said, I was able to get the expected output to a file by adding -outputfile <filename> to the Invoke-WebRequest command, and then referencing the file.
Wow! That was it! I know I tried the .RawContent method before and it was the same as .Content but something in the above modifications must have changed it! Thanks!