microsoftgraph / msgraph-sdk-powershell

Powershell SDK for Microsoft Graph
https://www.powershellgallery.com/packages/Microsoft.Graph
Other
694 stars 168 forks source link

Invoke-MgGraphRequest -Method GET ... Not returning all records. #2992

Open gjhardie opened 1 week ago

gjhardie commented 1 week ago

Describe the bug

I'm trying to get all the device configuration profiles from Intune. I've tried both of these with Microsoft.Graph and Microsoft.Beta:

  1. $response = Invoke-MgGraphRequest -Method GET -Uri "https://graph.microsoft.com/v1.0/deviceManagement/deviceConfigurations"
  2. $response = Invoke-MgGraphRequest -Method GET -Uri "https://graph.microsoft.com/beta/deviceManagement/deviceConfigurations"

The first returns 54 items then second 80. However, there are in fact 91Device Configuration policies.

Expected behavior

Expected either 1 or 2:

  1. $response.value.count return a value of 91
  2. $response.value.count return a value less than 91 and $response.'@odata.nextLink' to provide a link for the next items.

Neither of these happened.

How to reproduce

  1. In this instance there are 91 Device Configuration profiles in Intune. Given the most items were returned by URI: "https://graph.microsoft.com/beta/deviceManagement/deviceConfigurations" at least -gt 80 items are required to reproduce this.
  2. Microsoft.Graph or Microsoft.Beta module is installed.
  3. Connect-MgGraph -Scopes "DeviceManagementConfiguration.Read.All"
  4. $response = Invoke-MgGraphRequest -Method GET -Uri "https://graph.microsoft.com/v1.0/deviceManagement/deviceConfigurations"
  5. $response.value.count

SDK Version

2.23.0

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output

VERBOSE: GET https://graph.microsoft.com/beta/deviceManagement/deviceConfigurations with 0-byte payload DEBUG: GET /beta/deviceManagement/deviceConfigurations HTTP/1.1 HTTP: graph.microsoft.com User-Agent: Mozilla/5.0 (Windows NT 10.0; Microsoft Windows 10.0.22631; en-GB) PowerShell/5.1.22621.4111 Invoke-MgGraphRequest

VERBOSE: received 393337-byte response of content type application/json DEBUG: GET https://graph.microsoft.com/beta/deviceManagement/deviceConfigurations HTTP/1.1 200 OK Transfer-Encoding: chunked Vary: Accept-Encoding Strict-Transport-Security: max-age=31536000 request-id: ee554cd3-3516-4e1a-a039-e4a62b3b2791 client-request-id: 65043a5f-6d0c-4680-9ba5-94c4e35655f4 x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"UK South","Slice":"E","Ring":"5","ScaleUnit":"001","RoleInstance":"LN2PEPF000114DC"}} OData-Version: 4.0 Date: Tue, 08 Oct 2024 16:02:10 GMT Content-Encoding: gzip Content-Type: application/json; odata.metadata=minimal; odata.streaming=true; IEEE754Compatible=false; charset=utf-8

{"@odata.context":"https://graph.microsoft.com/beta/$metadata#deviceManagement/deviceConfigurations","value":[{"@odata.type":"#microsoft.graph.iosCustomConfiguration","id":"d3a0db21-d423-4ae4-a5ac-ec17d4284687", "lastModifiedDateTime":"2022-06-08T09:55:44.7654192Z","roleScopeTagIds": REDACTED}]}

Configuration

-OS: Windows 11 -Architecture x64 Name Value


PSVersion 5.1.22621.4111
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.22621.4111
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Other information

If one: $response= Get-MgDeviceManagementDeviceConfiguration -All $response.Count returns 54

This is the same count for: $response = Invoke-MgGraphRequest -Method GET -Uri "https://graph.microsoft.com/v1.0/deviceManagement/deviceConfigurations"

timayabi2020 commented 1 day ago

Hi @gjhardie kindly try and use this tool (https://developer.microsoft.com/en-us/graph/graph-explorer) and let us know if the behavior is the same.