Reputation: 29
Have made an application in AAD with Delegate access and made a PS to connect to Graph and run a query using this format:
$uri = "https://graph.microsoft.com/v1.0/devices?$filter=DeviceId eq '11111111-1111-1111-1111-111111111111'"
$method = "GET"
$query = Invoke-WebRequest -Method $method -Uri $uri -ContentType "application/json" -Headers @{Authorization = "Bearer $token"} -UseBasicParsing -ErrorAction Stop
Write-Host $query
$query instead of giving me only the result for the $filter I've applied, it returns all devices in my Tenant. I'm using the command as Microsoft intended so not sure why doesn't work.
My end-goal is to update 'DevicePhysicalId' only for the device I have the deviceId of but unfortunately I can's search in MSGraph using deviceId, have to use objectId instead. So either $filter works or I need a solution to work out with the list of all devices I have as result.
Thanks,
Stef
Upvotes: 0
Views: 1349
Reputation: 20660
Try to use PowerShell backtick character before $filter
clause.
Without backtick character PowerShell works with $filter
as with property
$uri = "https://graph.microsoft.com/v1.0/devices?$filter=DeviceId eq '11111111-1111-1111-1111-111111111111'"
Write-Host $uri
Uri is without $filter
clause
https://graph.microsoft.com/v1.0/devices?=DeviceId eq '11111111-1111-1111-1111-111111111111'
With backtick character
$uri = "https://graph.microsoft.com/v1.0/devices?`$filter=DeviceId eq '11111111-1111-1111-1111-111111111111'"
Write-Host $uri
Uri is
https://graph.microsoft.com/v1.0/devices?$filter=DeviceId eq '11111111-1111-1111-1111-111111111111'
Upvotes: 1