FunctionsPublic/Get-GraphAllGroups.ps1
function Get-GraphAllGroups { param([psobject]$accessToken) # # Get all existing groups # $responseBody = Invoke-RestMethod -Uri "https://graph.microsoft.com/v1.0/groups" -Headers @{"Authorization" = "Bearer $($accessToken.AccessTokenCredential.GetNetworkCredential().password)"} $jsonResponse = $responseBody | ConvertTo-JSON $groups = ConvertFrom-Json -InputObject $jsonResponse return $groups } |