From 24b94011a20802f6b842244bb593a2f6121ab35d Mon Sep 17 00:00:00 2001 From: Koen Zomers Date: Tue, 9 Jun 2020 22:48:14 +0200 Subject: [PATCH] Added HideFromAddressLists and HideFromOutlookClients to Set-PnPUnifiedGroup to allow for M365 Groups to be shown or hidden --- CHANGELOG.md | 2 ++ Commands/Graph/SetUnifiedGroup.cs | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5c340e62..c96ecdb07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,10 +8,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). ## [3.23.2007.0] (not yet released) ### Added +- Added `-HideFromAddressLists` and `-HideFromOutlookClients` to `Set-PnPUnifiedGroup` to allow for setting the visibility of Microsoft 365 Groups [PR #2717](https://github.com/pnp/PnP-PowerShell/pull/2717) ### Changed ### Contributors +- Koen Zomers [koenzomers] ## [3.22.2006.1] diff --git a/Commands/Graph/SetUnifiedGroup.cs b/Commands/Graph/SetUnifiedGroup.cs index 7730d2395..9374930d0 100644 --- a/Commands/Graph/SetUnifiedGroup.cs +++ b/Commands/Graph/SetUnifiedGroup.cs @@ -35,6 +35,10 @@ namespace SharePointPnP.PowerShell.Commands.Graph Code = @"PS:> Set-PnPUnifiedGroup -Identity $group -Owners demo@contoso.com", Remarks = "Sets demo@contoso.com as owner of the group.", SortOrder = 5)] + [CmdletExample( + Code = @"PS:> Set-PnPUnifiedGroup -Identity $group -HideFromOutlookClients:$false", + Remarks = "Ensures the provided group will be shown in Outlook clients.", + SortOrder = 6)] [CmdletMicrosoftGraphApiPermission(MicrosoftGraphApiPermission.Group_ReadWrite_All)] public class SetUnifiedGroup : PnPGraphCmdlet { @@ -62,6 +66,12 @@ public class SetUnifiedGroup : PnPGraphCmdlet [Parameter(Mandatory = false, HelpMessage = "Creates a Microsoft Teams team associated with created group")] public SwitchParameter CreateTeam; + [Parameter(Mandatory = false, HelpMessage = "Hides the group from the Global Address List")] + public bool? HideFromAddressLists; + + [Parameter(Mandatory = false, HelpMessage = "Hides the group from Outlook Clients")] + public bool? HideFromOutlookClients; + protected override void ExecuteCmdlet() { UnifiedGroupEntity group = null; @@ -98,6 +108,12 @@ protected override void ExecuteCmdlet() groupLogo: groupLogoStream, isPrivate: isPrivateGroup, createTeam: CreateTeam); + + if (ParameterSpecified(nameof(HideFromAddressLists)) || ParameterSpecified(nameof(HideFromOutlookClients))) + { + // For this scenario a separate call needs to be made + UnifiedGroupsUtility.SetUnifiedGroupVisibility(group.GroupId, AccessToken, HideFromAddressLists, HideFromOutlookClients); + } } else { @@ -106,4 +122,4 @@ protected override void ExecuteCmdlet() } } } -#endif \ No newline at end of file +#endif