AzureAD / MSAL.PS

MIT License
163 stars 29 forks source link

Incomplete results #21

Closed smwk closed 3 years ago

smwk commented 3 years ago

Not sure if it's an issue with Graph or the module (I suspect the former) but when I run various reports I get different results returned. An example is this table which shows the amount of Teams in my organization.

image

No Teams have been deleted and if I manually check the dashboard all the Teams are still there. The Powershell script does not return an error, it simply completes without returning all the results. I've tried adding a pause between calling the next page, which helped on some scripts, but not this one.

jazuntee commented 3 years ago

You are correct. This is specific to MS Graph, not MSAL.PS module.

MS Graph uses paging when returning large amounts of data. https://docs.microsoft.com/en-us/graph/paging

You could look at using the Microsoft.Graph PowerShell modules instead which can handle paging. If you still need to make the underlying REST calls, you could use the Invoke-RestMethodWithBearerAuth command I published in the MSIdentityTools module which has a parameter to automatically return all data from a query.

For Example:

Invoke-RestMethodWithBearerAuth -ClientApplication $ClientId -Scopes 'User.Read.All','Group.Read.All' -Method Get -Uri 'https://graph.microsoft.com/v1.0/users' -FollowODataNextLink
smwk commented 3 years ago

I was actually using paging already, but it seems large queries still cause problems. I'm re-writing my scripts to take this into account.

Thanks for the additional info, will try out Invoke-RestMethodWithBearerAuth.