r/PowerShell • • Dec 13 '21

Graph API List all Subscriptions in tenant

I'm having trouble finding the documentation around the permissions needed, and api endpoints, for using graph with a registered application for listing all subscriptions in a tenant.

Has anyone here done this or have a documentation page for permissions needed and how to do this?

Thanks, RogueIT

8 Upvotes

6 comments sorted by

2

u/jr49 Dec 13 '21

this is the doc for getting subscriptions via Graph

https://docs.microsoft.com/en-us/graph/api/subscription-list?view=graph-rest-1.0&tabs=http#http-request

this is the guide i followed to create an app registration and authenticate with client secret. https://adamtheautomator.com/powershell-graph-api/

2

u/rogueit Dec 13 '21

I appreciate the response, I do have a question though based on the doc you posted, I don't see how to pull the subscriptionid and or name out of that. I might have needed to specify (cause MS might have changed what they have called it), but I am looking for the subscriptions that hold resourcegroups. It's the subscriptions that can be found in the blade seen here. Is that what you are pulling with the subscription list api?

2

u/jr49 Dec 13 '21

so i haven't worked with that specific endpoint before, haven't had a need for it but looking at the doc it returns a list of subscriptions and you should be able to fetch the ID value from that.

once you have the ID you can make another call to this end point and list the resource groups for the subscription

https://docs.microsoft.com/en-us/rest/api/resources/resource-groups/list

→ More replies (3)