Hide Office 365 Group from GAL via Graph API

We can easily hide Office 365 Groups from Global Address List (GAL) by using the Set-UnifiedGroup cmdlet by setting the property HiddenFromAddressListsEnabled as True. You can refer this post for more details.

Set-UnifiedGroup "group_name" -HiddenFromAddressListsEnabled:$true

In some scenarios, we need to set this property using Graph API. Microsoft Graph introduced the property resourceBehaviorOptions which includes a set of options that are related to Exchange properties of the group. The property resourceBehaviorOptions includes the option HideGroupInOutlook which is equivalent to HiddenFromAddressListsEnabled.

Hide from GAL while creating new Office 365 Group using Graph API

The following Graph API call creates a new group and sets the option HideGroupInOutlook in resourceBehaviorOptions which in-turn hides the group from global address book in Outlook.

POST : https://graph.microsoft.com/v1.0/groups
Body :
{
  "description": "This is test group",
  "displayName": "TestO365Group",
  "groupTypes": [
    "Unified"
  ],
  "mailEnabled": true,
  "mailNickname": "TestO365Group",
  "securityEnabled": false,
  "resourceBehaviorOptions":["HideGroupInOutlook"]
}

Update GAL visibility in existing Office 365 Group using Graph API

As of now, the Graph REST API supports this option only when creating a new group and you can’t update the resourceBehaviorOptions property in existing groups.

Currently you will get below error when you try to edit this option in existing group.

PATCH : https://graph.microsoft.com/v1.0/groups/{id}
Body  :
{
  "resourceBehaviorOptions":["HideGroupInOutlook"]
}

Error :
"code": "Request_BadRequest",
"message": "Property cannot be updated because it is immutable."

Supported values in resourceBehaviorOptions:

  • AllowOnlyMembersToPost
  • CalendarMemberReadOnly
  • ConnectorsEnabled
  • HideGroupInOutlook
  • NotebookForLearningCommunitiesEnabled
  • ReportToOriginator
  • SharePointReadonlyForMembers
  • SubscriptionEnabled
  • SubscribeMembersToCalendarEvents
  • SubscribeMembersToCalendarEventsDisabled
  • SubscribeNewGroupMembers
  • WelcomeEmailDisabled
  • WelcomeEmailEnabled

Advertisement

2 thoughts on “Hide Office 365 Group from GAL via Graph API”

  1. Stumbled across this… Using resourceBehaviorOptions on existing groups has never materialised or changed, but instead you can patch with another property, which after a little replication time does end up setting in Exchange:

    Method – PATCH
    URI – https://graph.microsoft.com/beta/groups/{id}?$select=hideFromAddressLists
    Body – {“hideFromAddressLists”: true}

    Reply
  2. Wish something would work for HiddenGroupMembershipEnabled now exposed for distribution groups too but only in Exchange management module not graph

    Reply

Leave a Comment