FunctionsPublic/Find-GraphGroupByName.ps1
function Find-GraphGroupByName { param( [psobject]$accessToken, [string]$displayName ) # # Escape special characters in displayName and get corresponding # group by using its name. # $responseBody = Invoke-RestMethod -Uri "https://graph.microsoft.com/beta/groups?`$filter=displayName eq '$([System.Web.HttpUtility]::UrlEncode($displayName))'" ` -Headers @{"Authorization" = "Bearer $($accessToken.AccessTokenCredential.GetNetworkCredential().password)"} if($null -eq $responseBody.value) { return $null } else { return $responseBody.value } } |