Thursday, 5 September 2019

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

Advertisements
Advertisements

No comments:

Post a Comment