Skip to content
This repository was archived by the owner on Jan 19, 2021. It is now read-only.

Commit f0c63ca

Browse files
Merge pull request #2724 from KoenZomers/SetGroupVisibility2
Added HideFromAddressLists and HideFromOutlookClients to Set-PnPMicrosoft365Group
2 parents 0dfca16 + 837586b commit f0c63ca

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
1515
- Added the following cmdlets to add/remove/clear owners and members of Microsoft 365 Groups: `Add-PnPMicrosoft365GroupMember`, `Add-PnPMicrosoft365GroupOwner`, `Remove-PnPMicrosoft365GroupMember`, `Remove-PnPMicrosoft365GroupOwner`, `Clear-PnPMicrosoft365GroupMember`, `Clear-PnPMicrosoft365GroupOwner` [PR #2750](https://github.com/pnp/PnP-PowerShell/pull/2750)
1616
- Added Add-PnPTeamsChannel, Add-PnPTeamsTab, Add-PnPTeamsUser, Get-PnPTeamsApp, Get-PnPTeamsChannel, Get-PnPTeamsChannelMessage, Get-PnPTeamsTab, Get-PnPTeamsTeam, Get-PnPTeamsUser, New-PnPTeamsApp, New-PnPTeamsTeam, Remove-PnPTeamsChannel, Remove-PnPTeamsTab, Remove-PnPTeamsTeam, Remove-PnPTeamsUser, Set-PnPTeamsChannel, Set-PnPTeamsTab, Set-PnPTeamsTeam, Set-PnPTeamsPicture, Submit-PnPTeamsChannelMessage, Update-PnPTeamsApp cmdlets
1717
- Added Get-PnPFileVersion, Remove-PnPFileVersion, Restore-PnPFileVersion cmdlets
18+
- 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)
1819

1920
### Changed
2021
- Updated implementation of `Move-PnPFile` to now also support moving of files and folders accross site collections [PR #2749](https://github.com/pnp/PnP-PowerShell/pull/2749)

Commands/Graph/SetMicrosoft365Group.cs

+17-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ namespace SharePointPnP.PowerShell.Commands.Graph
3535
Code = @"PS:> Set-PnPMicrosoft365Group -Identity $group -Owners [email protected]",
3636
Remarks = "Sets [email protected] as owner of the group",
3737
SortOrder = 5)]
38+
[CmdletExample(
39+
Code = @"PS:> Set-PnPMicrosoft365Group -Identity $group -HideFromOutlookClients:$false",
40+
Remarks = "Ensures the provided group will be shown in Outlook clients",
41+
SortOrder = 6)]
3842
[CmdletRelatedLink(Text = "Documentation", Url = "https://docs.microsoft.com/graph/api/group-update")]
3943
[CmdletMicrosoftGraphApiPermission(MicrosoftGraphApiPermission.Group_ReadWrite_All)]
4044
public class SetMicrosoft365Group : PnPGraphCmdlet
@@ -63,6 +67,12 @@ public class SetMicrosoft365Group : PnPGraphCmdlet
6367
[Parameter(Mandatory = false, HelpMessage = "Creates a Microsoft Teams team associated with created group")]
6468
public SwitchParameter CreateTeam;
6569

70+
[Parameter(Mandatory = false, HelpMessage = "Hides the group from the Global Address List")]
71+
public bool? HideFromAddressLists;
72+
73+
[Parameter(Mandatory = false, HelpMessage = "Hides the group from Outlook Clients")]
74+
public bool? HideFromOutlookClients;
75+
6676
protected override void ExecuteCmdlet()
6777
{
6878
UnifiedGroupEntity group = null;
@@ -101,6 +111,12 @@ protected override void ExecuteCmdlet()
101111
groupLogo: groupLogoStream,
102112
isPrivate: isPrivateGroup,
103113
createTeam: CreateTeam);
114+
115+
if (ParameterSpecified(nameof(HideFromAddressLists)) || ParameterSpecified(nameof(HideFromOutlookClients)))
116+
{
117+
// For this scenario a separate call needs to be made
118+
UnifiedGroupsUtility.SetUnifiedGroupVisibility(group.GroupId, AccessToken, HideFromAddressLists, HideFromOutlookClients);
119+
}
104120
}
105121
catch(Exception e)
106122
{
@@ -115,4 +131,4 @@ protected override void ExecuteCmdlet()
115131
}
116132
}
117133
}
118-
#endif
134+
#endif

0 commit comments

Comments
 (0)