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

Commit

Permalink
Merge pull request #2724 from KoenZomers/SetGroupVisibility2
Browse files Browse the repository at this point in the history
Added HideFromAddressLists and HideFromOutlookClients to Set-PnPMicrosoft365Group
  • Loading branch information
erwinvanhunen authored Jul 13, 2020
2 parents 0dfca16 + 837586b commit f0c63ca
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- 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)
- 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
- Added Get-PnPFileVersion, Remove-PnPFileVersion, Restore-PnPFileVersion cmdlets
- 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
- 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)
Expand Down
18 changes: 17 additions & 1 deletion Commands/Graph/SetMicrosoft365Group.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ namespace SharePointPnP.PowerShell.Commands.Graph
Code = @"PS:> Set-PnPMicrosoft365Group -Identity $group -Owners demo@contoso.com",
Remarks = "Sets demo@contoso.com as owner of the group",
SortOrder = 5)]
[CmdletExample(
Code = @"PS:> Set-PnPMicrosoft365Group -Identity $group -HideFromOutlookClients:$false",
Remarks = "Ensures the provided group will be shown in Outlook clients",
SortOrder = 6)]
[CmdletRelatedLink(Text = "Documentation", Url = "https://docs.microsoft.com/graph/api/group-update")]
[CmdletMicrosoftGraphApiPermission(MicrosoftGraphApiPermission.Group_ReadWrite_All)]
public class SetMicrosoft365Group : PnPGraphCmdlet
Expand Down Expand Up @@ -63,6 +67,12 @@ public class SetMicrosoft365Group : 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;
Expand Down Expand Up @@ -101,6 +111,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);
}
}
catch(Exception e)
{
Expand All @@ -115,4 +131,4 @@ protected override void ExecuteCmdlet()
}
}
}
#endif
#endif

0 comments on commit f0c63ca

Please sign in to comment.