FunctionsPublic/Find-GraphGroupByName.ps1
function Find-GraphGroupByName { param( [psobject]$accessToken, [string]$displayName ) # # Get all existing groups # $responseBody = Invoke-RestMethod -Uri "https://graph.microsoft.com/beta/groups?`$filter=displayName eq '$($displayName)'" -Headers @{"Authorization" = "Bearer $($accessToken.AccessTokenCredential.GetNetworkCredential().password)"} if($null -eq $responseBody.value) { return $null } else { return $responseBody.value } } |