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