Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@pkbullock
Created November 11, 2020 00:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pkbullock/cbe486795848b55c5dc5498b2a83c1c2 to your computer and use it in GitHub Desktop.
Save pkbullock/cbe486795848b55c5dc5498b2a83c1c2 to your computer and use it in GitHub Desktop.
Get a list of groups that is associated to a team
Connect-PnPOnline -ClientId c53eb8da-8bdf-44f9-8718-1fb1bbbbbb `
-Thumbprint EC1E61510AEC35624AF78FEA763D00000000 `
-Tenant "tenant.co.uk" -Url "https://tenant.sharepoint.com"
$token = Get-PnPGraphAccessToken
# Create header with the access token
$header = @{ Authorization = "Bearer $($token)" }
#v1.0/Beta
$uri = 'https://graph.microsoft.com/Beta/groups' + `
'?$filter=resourceProvisioningOptions/Any(x:x eq ''Team'')' +
'&select=id,displayName'
# Make a simple rest call
$response = Invoke-RestMethod -Uri $uri -Headers $header -Method Get -ContentType "application/json"
# Lets see the result
$response.Value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment