From 43fff43e1015e75670c03de61f961204b4a0983e Mon Sep 17 00:00:00 2001 From: Koen Zomers Date: Sun, 21 Jun 2020 01:38:19 +0200 Subject: [PATCH 1/5] Clarified the Add-PnPUserToGroup cmdlet is for SharePoint groups, not for M365 Groups --- Commands/Principals/AddUserToGroup.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Commands/Principals/AddUserToGroup.cs b/Commands/Principals/AddUserToGroup.cs index 2d53686bb..e34fd417a 100644 --- a/Commands/Principals/AddUserToGroup.cs +++ b/Commands/Principals/AddUserToGroup.cs @@ -6,15 +6,15 @@ namespace SharePointPnP.PowerShell.Commands.Principals { [Cmdlet(VerbsCommon.Add, "PnPUserToGroup")] - [CmdletHelp("Adds a user to a group", + [CmdletHelp("Adds a user to a SharePoint group", Category = CmdletHelpCategory.Principals)] [CmdletExample( Code = @"PS:> Add-PnPUserToGroup -LoginName user@company.com -Identity 'Marketing Site Members'", - Remarks = @"Add the specified user to the group ""Marketing Site Members""", + Remarks = @"Add the specified user to the SharePoint group ""Marketing Site Members""", SortOrder = 1)] [CmdletExample( Code = @"PS:> Add-PnPUserToGroup -LoginName user@company.com -Identity 5", - Remarks = "Add the specified user to the group with Id 5", + Remarks = "Add the specified user to the SharePoint group with Id 5", SortOrder = 2)] public class AddUserToGroup : PnPWebCmdlet { @@ -22,9 +22,9 @@ public class AddUserToGroup : PnPWebCmdlet [Parameter(Mandatory = true, HelpMessage = "The login name of the user", ParameterSetName = "Internal")] public string LoginName; - [Parameter(Mandatory = true, HelpMessage = "The group id, group name or group object to add the user to.", ValueFromPipeline = true, ParameterSetName = "Internal")] + [Parameter(Mandatory = true, HelpMessage = "The SharePoint group id, SharePoint group name or SharePoint group object to add the user to", ValueFromPipeline = true, ParameterSetName = "Internal")] #if !ONPREMISES - [Parameter(Mandatory = true, HelpMessage = "The group id, group name or group object to add the user to.", ValueFromPipeline = true, ParameterSetName = "External")] + [Parameter(Mandatory = true, HelpMessage = "The SharePoint group id, SharePoint group name or SharePoint group object to add the user to", ValueFromPipeline = true, ParameterSetName = "External")] #endif public GroupPipeBind Identity; From 18420dd7e6e051a8732a364ea9bb825bc2d41ed0 Mon Sep 17 00:00:00 2001 From: Koen Zomers Date: Sun, 21 Jun 2020 02:59:03 +0200 Subject: [PATCH 2/5] Added the following cmdlets to add/remove/clear owners and members of Microsoft 365 Groups: `Add-PnPUnifiedGroupMember`, `Add-PnPUnifiedGroupOwner`, `Remove-PnPUnifiedGroupMember`, `Remove-PnPUnifiedGroupOwner`, `Clear-PnPUnifiedGroupMember`, `Clear-PnPUnifiedGroupOwner` --- CHANGELOG.md | 1 + Commands/Graph/AddUnifiedGroupMember.cs | 53 +++++++++++++++++++ Commands/Graph/AddUnifiedGroupOwner.cs | 53 +++++++++++++++++++ Commands/Graph/ClearUnifiedGroupMember.cs | 42 +++++++++++++++ Commands/Graph/ClearUnifiedGroupOwner.cs | 42 +++++++++++++++ Commands/Graph/GetUnifiedGroupMembers.cs | 4 +- Commands/Graph/GetUnifiedGroupOwners.cs | 6 +-- Commands/Graph/RemoveUnifiedGroupMember.cs | 45 ++++++++++++++++ Commands/Graph/RemoveUnifiedGroupOwner.cs | 45 ++++++++++++++++ .../SharePointPnP.PowerShell.Commands.csproj | 6 +++ 10 files changed, 290 insertions(+), 7 deletions(-) create mode 100644 Commands/Graph/AddUnifiedGroupMember.cs create mode 100644 Commands/Graph/AddUnifiedGroupOwner.cs create mode 100644 Commands/Graph/ClearUnifiedGroupMember.cs create mode 100644 Commands/Graph/ClearUnifiedGroupOwner.cs create mode 100644 Commands/Graph/RemoveUnifiedGroupMember.cs create mode 100644 Commands/Graph/RemoveUnifiedGroupOwner.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index b9bc823a3..807d667a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). ## [3.23.2007.0] (not yet released) ### Added +- Added the following cmdlets to add/remove/clear owners and members of Microsoft 365 Groups: `Add-PnPUnifiedGroupMember`, `Add-PnPUnifiedGroupOwner`, `Remove-PnPUnifiedGroupMember`, `Remove-PnPUnifiedGroupOwner`, `Clear-PnPUnifiedGroupMember`, `Clear-PnPUnifiedGroupOwner` ### Changed diff --git a/Commands/Graph/AddUnifiedGroupMember.cs b/Commands/Graph/AddUnifiedGroupMember.cs new file mode 100644 index 000000000..0b932fac3 --- /dev/null +++ b/Commands/Graph/AddUnifiedGroupMember.cs @@ -0,0 +1,53 @@ +#if !ONPREMISES +using OfficeDevPnP.Core.Entities; +using OfficeDevPnP.Core.Framework.Graph; +using SharePointPnP.PowerShell.CmdletHelpAttributes; +using SharePointPnP.PowerShell.Commands.Base; +using SharePointPnP.PowerShell.Commands.Base.PipeBinds; +using System.Management.Automation; + +namespace SharePointPnP.PowerShell.Commands.Graph +{ + [Cmdlet(VerbsCommon.Add, "PnPUnifiedGroupMember")] + [CmdletHelp("Adds members to a particular Microsoft 365 Group (aka Unified Group)", + Category = CmdletHelpCategory.Graph, + OutputTypeLink = "https://docs.microsoft.com/graph/api/group-post-owners", + SupportedPlatform = CmdletSupportedPlatform.Online)] + [CmdletExample( + Code = @"PS:> Add-PnPUnifiedGroupMember -Identity ""Project Team"" -Users ""john@contoso.onmicrosoft.com"",""jane@contoso.onmicrosoft.com""", + Remarks = @"Adds the provided two users as additional members to the Microsoft 365 Group named ""Project Team""", + SortOrder = 1)] + [CmdletExample( + Code = @"PS:> Add-PnPUnifiedGroupMember -Identity ""Project Team"" -Users ""john@contoso.onmicrosoft.com"",""jane@contoso.onmicrosoft.com"" -RemoveExisting", + Remarks = @"Sets the provided two users as the only members of the Microsoft 365 Group named ""Project Team"" by removing any current existing members first", + SortOrder = 2)] + [CmdletMicrosoftGraphApiPermission(MicrosoftGraphApiPermission.User_ReadWrite_All)] + [CmdletMicrosoftGraphApiPermission(MicrosoftGraphApiPermission.Group_ReadWrite_All)] + public class AddUnifiedGroupMember : PnPGraphCmdlet + { + [Parameter(Mandatory = true, ValueFromPipeline = true, HelpMessage = "The Identity of the Microsoft 365 Group to add members to")] + public UnifiedGroupPipeBind Identity; + + [Parameter(Mandatory = true, HelpMessage = "The UPN(s) of the user(s) to add to the Microsoft 365 Group as a member")] + public string[] Users; + + [Parameter(Mandatory = false, HelpMessage = "If provided, all existing members will be removed and only those provided through Users will become members")] + public SwitchParameter RemoveExisting; + + protected override void ExecuteCmdlet() + { + UnifiedGroupEntity group = null; + + if (Identity != null) + { + group = Identity.GetGroup(AccessToken); + } + + if (group != null) + { + UnifiedGroupsUtility.AddUnifiedGroupMembers(group.GroupId, Users, AccessToken, RemoveExisting.ToBool()); + } + } + } +} +#endif \ No newline at end of file diff --git a/Commands/Graph/AddUnifiedGroupOwner.cs b/Commands/Graph/AddUnifiedGroupOwner.cs new file mode 100644 index 000000000..bfd9dacff --- /dev/null +++ b/Commands/Graph/AddUnifiedGroupOwner.cs @@ -0,0 +1,53 @@ +#if !ONPREMISES +using OfficeDevPnP.Core.Entities; +using OfficeDevPnP.Core.Framework.Graph; +using SharePointPnP.PowerShell.CmdletHelpAttributes; +using SharePointPnP.PowerShell.Commands.Base; +using SharePointPnP.PowerShell.Commands.Base.PipeBinds; +using System.Management.Automation; + +namespace SharePointPnP.PowerShell.Commands.Graph +{ + [Cmdlet(VerbsCommon.Add, "PnPUnifiedGroupOwner")] + [CmdletHelp("Adds owners to a particular Microsoft 365 Group (aka Unified Group)", + Category = CmdletHelpCategory.Graph, + OutputTypeLink = "https://docs.microsoft.com/graph/api/group-post-owners", + SupportedPlatform = CmdletSupportedPlatform.Online)] + [CmdletExample( + Code = @"PS:> Add-PnPUnifiedGroupOwner -Identity ""Project Team"" -Users ""john@contoso.onmicrosoft.com"",""jane@contoso.onmicrosoft.com""", + Remarks = @"Adds the provided two users as additional owners to the Microsoft 365 Group named ""Project Team""", + SortOrder = 1)] + [CmdletExample( + Code = @"PS:> Add-PnPUnifiedGroupOwner -Identity ""Project Team"" -Users ""john@contoso.onmicrosoft.com"",""jane@contoso.onmicrosoft.com"" -RemoveExisting", + Remarks = @"Sets the provided two users as the only owners of the Microsoft 365 Group named ""Project Team"" by removing any current existing owners first", + SortOrder = 2)] + [CmdletMicrosoftGraphApiPermission(MicrosoftGraphApiPermission.User_ReadWrite_All)] + [CmdletMicrosoftGraphApiPermission(MicrosoftGraphApiPermission.Group_ReadWrite_All)] + public class AddUnifiedGroupOwner : PnPGraphCmdlet + { + [Parameter(Mandatory = true, ValueFromPipeline = true, HelpMessage = "The Identity of the Microsoft 365 Group to add owners to")] + public UnifiedGroupPipeBind Identity; + + [Parameter(Mandatory = true, HelpMessage = "The UPN(s) of the user(s) to add to the Microsoft 365 Group as an owner")] + public string[] Users; + + [Parameter(Mandatory = false, HelpMessage = "If provided, all existing owners will be removed and only those provided through Users will become owners")] + public SwitchParameter RemoveExisting; + + protected override void ExecuteCmdlet() + { + UnifiedGroupEntity group = null; + + if (Identity != null) + { + group = Identity.GetGroup(AccessToken); + } + + if (group != null) + { + UnifiedGroupsUtility.AddUnifiedGroupOwners(group.GroupId, Users, AccessToken, RemoveExisting.ToBool()); + } + } + } +} +#endif \ No newline at end of file diff --git a/Commands/Graph/ClearUnifiedGroupMember.cs b/Commands/Graph/ClearUnifiedGroupMember.cs new file mode 100644 index 000000000..de816bd24 --- /dev/null +++ b/Commands/Graph/ClearUnifiedGroupMember.cs @@ -0,0 +1,42 @@ +#if !ONPREMISES +using OfficeDevPnP.Core.Entities; +using OfficeDevPnP.Core.Framework.Graph; +using SharePointPnP.PowerShell.CmdletHelpAttributes; +using SharePointPnP.PowerShell.Commands.Base; +using SharePointPnP.PowerShell.Commands.Base.PipeBinds; +using System.Management.Automation; + +namespace SharePointPnP.PowerShell.Commands.Graph +{ + [Cmdlet(VerbsCommon.Clear, "PnPUnifiedGroupMember")] + [CmdletHelp("Removes all current members from a particular Microsoft 365 Group (aka Unified Group)", + Category = CmdletHelpCategory.Graph, + OutputTypeLink = "https://docs.microsoft.com/graph/api/group-delete-members", + SupportedPlatform = CmdletSupportedPlatform.Online)] + [CmdletExample( + Code = @"PS:> Clear-PnPUnifiedGroupMember -Identity ""Project Team""", + Remarks = @"Removes all the current members from the Microsoft 365 Group named ""Project Team""", + SortOrder = 1)] + [CmdletMicrosoftGraphApiPermission(MicrosoftGraphApiPermission.Group_ReadWrite_All | MicrosoftGraphApiPermission.Directory_ReadWrite_All | MicrosoftGraphApiPermission.GroupMember_ReadWrite_All)] + public class ClearUnifiedGroupMember : PnPGraphCmdlet + { + [Parameter(Mandatory = true, ValueFromPipeline = true, HelpMessage = "The Identity of the Microsoft 365 Group to remove all members from")] + public UnifiedGroupPipeBind Identity; + + protected override void ExecuteCmdlet() + { + UnifiedGroupEntity group = null; + + if (Identity != null) + { + group = Identity.GetGroup(AccessToken); + } + + if (group != null) + { + UnifiedGroupsUtility.ClearUnifiedGroupMembers(group.GroupId, AccessToken); + } + } + } +} +#endif \ No newline at end of file diff --git a/Commands/Graph/ClearUnifiedGroupOwner.cs b/Commands/Graph/ClearUnifiedGroupOwner.cs new file mode 100644 index 000000000..a7f65de4c --- /dev/null +++ b/Commands/Graph/ClearUnifiedGroupOwner.cs @@ -0,0 +1,42 @@ +#if !ONPREMISES +using OfficeDevPnP.Core.Entities; +using OfficeDevPnP.Core.Framework.Graph; +using SharePointPnP.PowerShell.CmdletHelpAttributes; +using SharePointPnP.PowerShell.Commands.Base; +using SharePointPnP.PowerShell.Commands.Base.PipeBinds; +using System.Management.Automation; + +namespace SharePointPnP.PowerShell.Commands.Graph +{ + [Cmdlet(VerbsCommon.Clear, "PnPUnifiedGroupOwner")] + [CmdletHelp("Removes all current owners from a particular Microsoft 365 Group (aka Unified Group)", + Category = CmdletHelpCategory.Graph, + OutputTypeLink = "https://docs.microsoft.com/graph/api/group-delete-owners", + SupportedPlatform = CmdletSupportedPlatform.Online)] + [CmdletExample( + Code = @"PS:> Clear-PnPUnifiedGroupOwner -Identity ""Project Team""", + Remarks = @"Removes all the current owners from the Microsoft 365 Group named ""Project Team""", + SortOrder = 1)] + [CmdletMicrosoftGraphApiPermission(MicrosoftGraphApiPermission.Group_ReadWrite_All | MicrosoftGraphApiPermission.Directory_ReadWrite_All)] + public class ClearUnifiedGroupOwner : PnPGraphCmdlet + { + [Parameter(Mandatory = true, ValueFromPipeline = true, HelpMessage = "The Identity of the Microsoft 365 Group to remove all owners from")] + public UnifiedGroupPipeBind Identity; + + protected override void ExecuteCmdlet() + { + UnifiedGroupEntity group = null; + + if (Identity != null) + { + group = Identity.GetGroup(AccessToken); + } + + if (group != null) + { + UnifiedGroupsUtility.ClearUnifiedGroupOwners(group.GroupId, AccessToken); + } + } + } +} +#endif \ No newline at end of file diff --git a/Commands/Graph/GetUnifiedGroupMembers.cs b/Commands/Graph/GetUnifiedGroupMembers.cs index 098ea4d63..358c02449 100644 --- a/Commands/Graph/GetUnifiedGroupMembers.cs +++ b/Commands/Graph/GetUnifiedGroupMembers.cs @@ -39,12 +39,10 @@ protected override void ExecuteCmdlet() if (group != null) { - // Get members of the group. - + // Get members of the group List members = UnifiedGroupsUtility.GetUnifiedGroupMembers(group, AccessToken); WriteObject(members); } - } } } diff --git a/Commands/Graph/GetUnifiedGroupOwners.cs b/Commands/Graph/GetUnifiedGroupOwners.cs index a52732b4f..4a3a36718 100644 --- a/Commands/Graph/GetUnifiedGroupOwners.cs +++ b/Commands/Graph/GetUnifiedGroupOwners.cs @@ -25,7 +25,7 @@ namespace SharePointPnP.PowerShell.Commands.Graph [CmdletMicrosoftGraphApiPermission(MicrosoftGraphApiPermission.Group_Read_All | MicrosoftGraphApiPermission.User_Read_All | MicrosoftGraphApiPermission.Group_ReadWrite_All | MicrosoftGraphApiPermission.User_ReadWrite_All)] public class GetUnifiedGroupOwners : PnPGraphCmdlet { - [Parameter(Mandatory = true, ValueFromPipeline = true, HelpMessage = "The Identity of the Microsoft 365 Group.")] + [Parameter(Mandatory = true, ValueFromPipeline = true, HelpMessage = "The Identity of the Microsoft 365 Group")] public UnifiedGroupPipeBind Identity; protected override void ExecuteCmdlet() @@ -39,12 +39,10 @@ protected override void ExecuteCmdlet() if (group != null) { - // Get Owners of the group. - + // Get Owners of the group List owners = UnifiedGroupsUtility.GetUnifiedGroupOwners(group, AccessToken); WriteObject(owners); } - } } } diff --git a/Commands/Graph/RemoveUnifiedGroupMember.cs b/Commands/Graph/RemoveUnifiedGroupMember.cs new file mode 100644 index 000000000..3535e8c07 --- /dev/null +++ b/Commands/Graph/RemoveUnifiedGroupMember.cs @@ -0,0 +1,45 @@ +#if !ONPREMISES +using OfficeDevPnP.Core.Entities; +using OfficeDevPnP.Core.Framework.Graph; +using SharePointPnP.PowerShell.CmdletHelpAttributes; +using SharePointPnP.PowerShell.Commands.Base; +using SharePointPnP.PowerShell.Commands.Base.PipeBinds; +using System.Management.Automation; + +namespace SharePointPnP.PowerShell.Commands.Graph +{ + [Cmdlet(VerbsCommon.Remove, "PnPUnifiedGroupMember")] + [CmdletHelp("Removes members from a particular Microsoft 365 Group (aka Unified Group)", + Category = CmdletHelpCategory.Graph, + OutputTypeLink = "https://docs.microsoft.com/graph/api/group-delete-members", + SupportedPlatform = CmdletSupportedPlatform.Online)] + [CmdletExample( + Code = @"PS:> Remove-PnPUnifiedGroupMember -Identity ""Project Team"" -Users ""john@contoso.onmicrosoft.com"",""jane@contoso.onmicrosoft.com""", + Remarks = @"Removes the provided two users as members from the Microsoft 365 Group named ""Project Team""", + SortOrder = 1)] + [CmdletMicrosoftGraphApiPermission(MicrosoftGraphApiPermission.Group_ReadWrite_All | MicrosoftGraphApiPermission.GroupMember_ReadWrite_All | MicrosoftGraphApiPermission.Directory_ReadWrite_All)] + public class RemoveUnifiedGroupMember : PnPGraphCmdlet + { + [Parameter(Mandatory = true, ValueFromPipeline = true, HelpMessage = "The Identity of the Microsoft 365 Group to remove members from")] + public UnifiedGroupPipeBind Identity; + + [Parameter(Mandatory = true, HelpMessage = "The UPN(s) of the user(s) to remove as members from the Microsoft 365 Group")] + public string[] Users; + + protected override void ExecuteCmdlet() + { + UnifiedGroupEntity group = null; + + if (Identity != null) + { + group = Identity.GetGroup(AccessToken); + } + + if (group != null) + { + UnifiedGroupsUtility.RemoveUnifiedGroupMembers(group.GroupId, Users, AccessToken); + } + } + } +} +#endif \ No newline at end of file diff --git a/Commands/Graph/RemoveUnifiedGroupOwner.cs b/Commands/Graph/RemoveUnifiedGroupOwner.cs new file mode 100644 index 000000000..9ebd629a1 --- /dev/null +++ b/Commands/Graph/RemoveUnifiedGroupOwner.cs @@ -0,0 +1,45 @@ +#if !ONPREMISES +using OfficeDevPnP.Core.Entities; +using OfficeDevPnP.Core.Framework.Graph; +using SharePointPnP.PowerShell.CmdletHelpAttributes; +using SharePointPnP.PowerShell.Commands.Base; +using SharePointPnP.PowerShell.Commands.Base.PipeBinds; +using System.Management.Automation; + +namespace SharePointPnP.PowerShell.Commands.Graph +{ + [Cmdlet(VerbsCommon.Remove, "PnPUnifiedGroupOwner")] + [CmdletHelp("Removes owners from a particular Microsoft 365 Group (aka Unified Group)", + Category = CmdletHelpCategory.Graph, + OutputTypeLink = "https://docs.microsoft.com/graph/api/group-delete-owners", + SupportedPlatform = CmdletSupportedPlatform.Online)] + [CmdletExample( + Code = @"PS:> Remove-PnPUnifiedGroupOwner -Identity ""Project Team"" -Users ""john@contoso.onmicrosoft.com"",""jane@contoso.onmicrosoft.com""", + Remarks = @"Removes the provided two users as owners from the Microsoft 365 Group named ""Project Team""", + SortOrder = 1)] + [CmdletMicrosoftGraphApiPermission(MicrosoftGraphApiPermission.Group_ReadWrite_All | MicrosoftGraphApiPermission.Directory_ReadWrite_All)] + public class RemoveUnifiedGroupOwner : PnPGraphCmdlet + { + [Parameter(Mandatory = true, ValueFromPipeline = true, HelpMessage = "The Identity of the Microsoft 365 Group to remove owners from")] + public UnifiedGroupPipeBind Identity; + + [Parameter(Mandatory = true, HelpMessage = "The UPN(s) of the user(s) to remove as owners from the Microsoft 365 Group")] + public string[] Users; + + protected override void ExecuteCmdlet() + { + UnifiedGroupEntity group = null; + + if (Identity != null) + { + group = Identity.GetGroup(AccessToken); + } + + if (group != null) + { + UnifiedGroupsUtility.RemoveUnifiedGroupOwners(group.GroupId, Users, AccessToken); + } + } + } +} +#endif \ No newline at end of file diff --git a/Commands/SharePointPnP.PowerShell.Commands.csproj b/Commands/SharePointPnP.PowerShell.Commands.csproj index ed7d2865d..72ebe6852 100644 --- a/Commands/SharePointPnP.PowerShell.Commands.csproj +++ b/Commands/SharePointPnP.PowerShell.Commands.csproj @@ -624,6 +624,11 @@ + + + + + @@ -668,6 +673,7 @@ + From 20acbe78489e0e41a49fd2d8f94759f59ee88772 Mon Sep 17 00:00:00 2001 From: Koen Zomers Date: Sun, 21 Jun 2020 03:06:32 +0200 Subject: [PATCH 3/5] Added PR reference --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 807d667a5..a2133f85f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,12 +8,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). ## [3.23.2007.0] (not yet released) ### Added -- Added the following cmdlets to add/remove/clear owners and members of Microsoft 365 Groups: `Add-PnPUnifiedGroupMember`, `Add-PnPUnifiedGroupOwner`, `Remove-PnPUnifiedGroupMember`, `Remove-PnPUnifiedGroupOwner`, `Clear-PnPUnifiedGroupMember`, `Clear-PnPUnifiedGroupOwner` +- Added the following cmdlets to add/remove/clear owners and members of Microsoft 365 Groups: `Add-PnPUnifiedGroupMember`, `Add-PnPUnifiedGroupOwner`, `Remove-PnPUnifiedGroupMember`, `Remove-PnPUnifiedGroupOwner`, `Clear-PnPUnifiedGroupMember`, `Clear-PnPUnifiedGroupOwner` [PR #2750](https://github.com/pnp/PnP-PowerShell/pull/2750) ### Changed ### Contributors - Gautam Sheth [gautamdsheth] +- Koen Zomers [koenzomers] ## [3.22.2006.2] From 4a9d72d95efc0a7a596e2fccc52788e231a2e324 Mon Sep 17 00:00:00 2001 From: Koen Zomers Date: Thu, 2 Jul 2020 00:22:35 +0200 Subject: [PATCH 4/5] Renamed cmdlets from UnifiedGroup to Microsoft365Group adding an alias for UnifiedGroup for backwards compatibility with the other M365 Group cmdlets, updated documentarion URL --- ...GroupMember.cs => AddMicrosoft365GroupMember.cs} | 13 +++++++------ ...edGroupOwner.cs => AddMicrosoft365GroupOwner.cs} | 12 +++++++----- ...oupMember.cs => ClearMicrosoft365GroupMember.cs} | 11 ++++++----- ...GroupOwner.cs => ClearMicrosoft365GroupOwner.cs} | 9 +++++---- ...upMember.cs => RemoveMicrosoft365GroupMember.cs} | 11 ++++++----- ...roupOwner.cs => RemoveMicrosoft365GroupOwner.cs} | 11 ++++++----- Commands/SharePointPnP.PowerShell.Commands.csproj | 12 ++++++------ 7 files changed, 43 insertions(+), 36 deletions(-) rename Commands/Graph/{AddUnifiedGroupMember.cs => AddMicrosoft365GroupMember.cs} (77%) rename Commands/Graph/{AddUnifiedGroupOwner.cs => AddMicrosoft365GroupOwner.cs} (78%) rename Commands/Graph/{ClearUnifiedGroupMember.cs => ClearMicrosoft365GroupMember.cs} (78%) rename Commands/Graph/{ClearUnifiedGroupOwner.cs => ClearMicrosoft365GroupOwner.cs} (79%) rename Commands/Graph/{RemoveUnifiedGroupMember.cs => RemoveMicrosoft365GroupMember.cs} (78%) rename Commands/Graph/{RemoveUnifiedGroupOwner.cs => RemoveMicrosoft365GroupOwner.cs} (77%) diff --git a/Commands/Graph/AddUnifiedGroupMember.cs b/Commands/Graph/AddMicrosoft365GroupMember.cs similarity index 77% rename from Commands/Graph/AddUnifiedGroupMember.cs rename to Commands/Graph/AddMicrosoft365GroupMember.cs index 0b932fac3..19cb591d9 100644 --- a/Commands/Graph/AddUnifiedGroupMember.cs +++ b/Commands/Graph/AddMicrosoft365GroupMember.cs @@ -8,22 +8,23 @@ namespace SharePointPnP.PowerShell.Commands.Graph { - [Cmdlet(VerbsCommon.Add, "PnPUnifiedGroupMember")] - [CmdletHelp("Adds members to a particular Microsoft 365 Group (aka Unified Group)", + [Cmdlet(VerbsCommon.Add, "PnPMicrosoft365GroupMember")] + [Alias("Add-PnPUnifiedGroupMember")] + [CmdletHelp("Adds members to a particular Microsoft 365 Group", Category = CmdletHelpCategory.Graph, - OutputTypeLink = "https://docs.microsoft.com/graph/api/group-post-owners", SupportedPlatform = CmdletSupportedPlatform.Online)] [CmdletExample( - Code = @"PS:> Add-PnPUnifiedGroupMember -Identity ""Project Team"" -Users ""john@contoso.onmicrosoft.com"",""jane@contoso.onmicrosoft.com""", + Code = @"PS:> Add-PnPMicrosoft365GroupMember -Identity ""Project Team"" -Users ""john@contoso.onmicrosoft.com"",""jane@contoso.onmicrosoft.com""", Remarks = @"Adds the provided two users as additional members to the Microsoft 365 Group named ""Project Team""", SortOrder = 1)] [CmdletExample( - Code = @"PS:> Add-PnPUnifiedGroupMember -Identity ""Project Team"" -Users ""john@contoso.onmicrosoft.com"",""jane@contoso.onmicrosoft.com"" -RemoveExisting", + Code = @"PS:> Add-PnPMicrosoft365GroupMember -Identity ""Project Team"" -Users ""john@contoso.onmicrosoft.com"",""jane@contoso.onmicrosoft.com"" -RemoveExisting", Remarks = @"Sets the provided two users as the only members of the Microsoft 365 Group named ""Project Team"" by removing any current existing members first", SortOrder = 2)] + [CmdletRelatedLink(Text = "Documentation", Url = "https://docs.microsoft.com/graph/api/group-post-members")] [CmdletMicrosoftGraphApiPermission(MicrosoftGraphApiPermission.User_ReadWrite_All)] [CmdletMicrosoftGraphApiPermission(MicrosoftGraphApiPermission.Group_ReadWrite_All)] - public class AddUnifiedGroupMember : PnPGraphCmdlet + public class AddMicrosoft365GroupMember : PnPGraphCmdlet { [Parameter(Mandatory = true, ValueFromPipeline = true, HelpMessage = "The Identity of the Microsoft 365 Group to add members to")] public UnifiedGroupPipeBind Identity; diff --git a/Commands/Graph/AddUnifiedGroupOwner.cs b/Commands/Graph/AddMicrosoft365GroupOwner.cs similarity index 78% rename from Commands/Graph/AddUnifiedGroupOwner.cs rename to Commands/Graph/AddMicrosoft365GroupOwner.cs index bfd9dacff..f64975bd6 100644 --- a/Commands/Graph/AddUnifiedGroupOwner.cs +++ b/Commands/Graph/AddMicrosoft365GroupOwner.cs @@ -8,22 +8,24 @@ namespace SharePointPnP.PowerShell.Commands.Graph { - [Cmdlet(VerbsCommon.Add, "PnPUnifiedGroupOwner")] - [CmdletHelp("Adds owners to a particular Microsoft 365 Group (aka Unified Group)", + [Cmdlet(VerbsCommon.Add, "PnPMicrosoft365GroupOwner")] + [Alias("Add-PnPUnifiedGroupOwner")] + [CmdletHelp("Adds owners to a particular Microsoft 365 Group", Category = CmdletHelpCategory.Graph, OutputTypeLink = "https://docs.microsoft.com/graph/api/group-post-owners", SupportedPlatform = CmdletSupportedPlatform.Online)] [CmdletExample( - Code = @"PS:> Add-PnPUnifiedGroupOwner -Identity ""Project Team"" -Users ""john@contoso.onmicrosoft.com"",""jane@contoso.onmicrosoft.com""", + Code = @"PS:> Add-PnPMicrosoft365GroupOwner -Identity ""Project Team"" -Users ""john@contoso.onmicrosoft.com"",""jane@contoso.onmicrosoft.com""", Remarks = @"Adds the provided two users as additional owners to the Microsoft 365 Group named ""Project Team""", SortOrder = 1)] [CmdletExample( - Code = @"PS:> Add-PnPUnifiedGroupOwner -Identity ""Project Team"" -Users ""john@contoso.onmicrosoft.com"",""jane@contoso.onmicrosoft.com"" -RemoveExisting", + Code = @"PS:> Add-PnPMicrosoft365GroupOwner -Identity ""Project Team"" -Users ""john@contoso.onmicrosoft.com"",""jane@contoso.onmicrosoft.com"" -RemoveExisting", Remarks = @"Sets the provided two users as the only owners of the Microsoft 365 Group named ""Project Team"" by removing any current existing owners first", SortOrder = 2)] + [CmdletRelatedLink(Text = "Documentation", Url = "https://docs.microsoft.com/graph/api/group-post-owners")] [CmdletMicrosoftGraphApiPermission(MicrosoftGraphApiPermission.User_ReadWrite_All)] [CmdletMicrosoftGraphApiPermission(MicrosoftGraphApiPermission.Group_ReadWrite_All)] - public class AddUnifiedGroupOwner : PnPGraphCmdlet + public class AddMicrosoft365GroupOwner : PnPGraphCmdlet { [Parameter(Mandatory = true, ValueFromPipeline = true, HelpMessage = "The Identity of the Microsoft 365 Group to add owners to")] public UnifiedGroupPipeBind Identity; diff --git a/Commands/Graph/ClearUnifiedGroupMember.cs b/Commands/Graph/ClearMicrosoft365GroupMember.cs similarity index 78% rename from Commands/Graph/ClearUnifiedGroupMember.cs rename to Commands/Graph/ClearMicrosoft365GroupMember.cs index de816bd24..54903f967 100644 --- a/Commands/Graph/ClearUnifiedGroupMember.cs +++ b/Commands/Graph/ClearMicrosoft365GroupMember.cs @@ -8,17 +8,18 @@ namespace SharePointPnP.PowerShell.Commands.Graph { - [Cmdlet(VerbsCommon.Clear, "PnPUnifiedGroupMember")] - [CmdletHelp("Removes all current members from a particular Microsoft 365 Group (aka Unified Group)", + [Cmdlet(VerbsCommon.Clear, "PnPMicrosoft365GroupMember")] + [Alias("Clear-PnPMicrosoft365GroupMember")] + [CmdletHelp("Removes all current members from a particular Microsoft 365 Group", Category = CmdletHelpCategory.Graph, - OutputTypeLink = "https://docs.microsoft.com/graph/api/group-delete-members", SupportedPlatform = CmdletSupportedPlatform.Online)] [CmdletExample( - Code = @"PS:> Clear-PnPUnifiedGroupMember -Identity ""Project Team""", + Code = @"PS:> Clear-PnPMicrosoft365GroupMember -Identity ""Project Team""", Remarks = @"Removes all the current members from the Microsoft 365 Group named ""Project Team""", SortOrder = 1)] + [CmdletRelatedLink(Text = "Documentation", Url = "https://docs.microsoft.com/graph/api/group-delete-members")] [CmdletMicrosoftGraphApiPermission(MicrosoftGraphApiPermission.Group_ReadWrite_All | MicrosoftGraphApiPermission.Directory_ReadWrite_All | MicrosoftGraphApiPermission.GroupMember_ReadWrite_All)] - public class ClearUnifiedGroupMember : PnPGraphCmdlet + public class ClearMicrosoft365GroupMember : PnPGraphCmdlet { [Parameter(Mandatory = true, ValueFromPipeline = true, HelpMessage = "The Identity of the Microsoft 365 Group to remove all members from")] public UnifiedGroupPipeBind Identity; diff --git a/Commands/Graph/ClearUnifiedGroupOwner.cs b/Commands/Graph/ClearMicrosoft365GroupOwner.cs similarity index 79% rename from Commands/Graph/ClearUnifiedGroupOwner.cs rename to Commands/Graph/ClearMicrosoft365GroupOwner.cs index a7f65de4c..c1d1dec27 100644 --- a/Commands/Graph/ClearUnifiedGroupOwner.cs +++ b/Commands/Graph/ClearMicrosoft365GroupOwner.cs @@ -8,17 +8,18 @@ namespace SharePointPnP.PowerShell.Commands.Graph { - [Cmdlet(VerbsCommon.Clear, "PnPUnifiedGroupOwner")] + [Cmdlet(VerbsCommon.Clear, "PnPMicrosoft365GroupOwner")] + [Alias("Clear-PnPUnifiedGroupOwner")] [CmdletHelp("Removes all current owners from a particular Microsoft 365 Group (aka Unified Group)", Category = CmdletHelpCategory.Graph, - OutputTypeLink = "https://docs.microsoft.com/graph/api/group-delete-owners", SupportedPlatform = CmdletSupportedPlatform.Online)] [CmdletExample( - Code = @"PS:> Clear-PnPUnifiedGroupOwner -Identity ""Project Team""", + Code = @"PS:> Clear-PnPMicrosoft365GroupOwner -Identity ""Project Team""", Remarks = @"Removes all the current owners from the Microsoft 365 Group named ""Project Team""", SortOrder = 1)] + [CmdletRelatedLink(Text = "Documentation", Url = "https://docs.microsoft.com/graph/api/group-delete-owners")] [CmdletMicrosoftGraphApiPermission(MicrosoftGraphApiPermission.Group_ReadWrite_All | MicrosoftGraphApiPermission.Directory_ReadWrite_All)] - public class ClearUnifiedGroupOwner : PnPGraphCmdlet + public class ClearMicrosoft365GroupOwner : PnPGraphCmdlet { [Parameter(Mandatory = true, ValueFromPipeline = true, HelpMessage = "The Identity of the Microsoft 365 Group to remove all owners from")] public UnifiedGroupPipeBind Identity; diff --git a/Commands/Graph/RemoveUnifiedGroupMember.cs b/Commands/Graph/RemoveMicrosoft365GroupMember.cs similarity index 78% rename from Commands/Graph/RemoveUnifiedGroupMember.cs rename to Commands/Graph/RemoveMicrosoft365GroupMember.cs index 3535e8c07..c21e8852e 100644 --- a/Commands/Graph/RemoveUnifiedGroupMember.cs +++ b/Commands/Graph/RemoveMicrosoft365GroupMember.cs @@ -8,17 +8,18 @@ namespace SharePointPnP.PowerShell.Commands.Graph { - [Cmdlet(VerbsCommon.Remove, "PnPUnifiedGroupMember")] - [CmdletHelp("Removes members from a particular Microsoft 365 Group (aka Unified Group)", + [Cmdlet(VerbsCommon.Remove, "PnPMicrosoft365GroupMember")] + [Alias("Remove-PnPUnifiedGroupMember")] + [CmdletHelp("Removes members from a particular Microsoft 365 Group", Category = CmdletHelpCategory.Graph, - OutputTypeLink = "https://docs.microsoft.com/graph/api/group-delete-members", SupportedPlatform = CmdletSupportedPlatform.Online)] [CmdletExample( - Code = @"PS:> Remove-PnPUnifiedGroupMember -Identity ""Project Team"" -Users ""john@contoso.onmicrosoft.com"",""jane@contoso.onmicrosoft.com""", + Code = @"PS:> Remove-PnPMicrosoft365GroupMember -Identity ""Project Team"" -Users ""john@contoso.onmicrosoft.com"",""jane@contoso.onmicrosoft.com""", Remarks = @"Removes the provided two users as members from the Microsoft 365 Group named ""Project Team""", SortOrder = 1)] + [CmdletRelatedLink(Text = "Documentation", Url = "https://docs.microsoft.com/graph/api/group-delete-members")] [CmdletMicrosoftGraphApiPermission(MicrosoftGraphApiPermission.Group_ReadWrite_All | MicrosoftGraphApiPermission.GroupMember_ReadWrite_All | MicrosoftGraphApiPermission.Directory_ReadWrite_All)] - public class RemoveUnifiedGroupMember : PnPGraphCmdlet + public class RemoveMicrosoft365GroupMember : PnPGraphCmdlet { [Parameter(Mandatory = true, ValueFromPipeline = true, HelpMessage = "The Identity of the Microsoft 365 Group to remove members from")] public UnifiedGroupPipeBind Identity; diff --git a/Commands/Graph/RemoveUnifiedGroupOwner.cs b/Commands/Graph/RemoveMicrosoft365GroupOwner.cs similarity index 77% rename from Commands/Graph/RemoveUnifiedGroupOwner.cs rename to Commands/Graph/RemoveMicrosoft365GroupOwner.cs index 9ebd629a1..296d22bb3 100644 --- a/Commands/Graph/RemoveUnifiedGroupOwner.cs +++ b/Commands/Graph/RemoveMicrosoft365GroupOwner.cs @@ -8,17 +8,18 @@ namespace SharePointPnP.PowerShell.Commands.Graph { - [Cmdlet(VerbsCommon.Remove, "PnPUnifiedGroupOwner")] - [CmdletHelp("Removes owners from a particular Microsoft 365 Group (aka Unified Group)", + [Cmdlet(VerbsCommon.Remove, "PnPMicrosoft365GroupOwner")] + [Alias("Remove-PnPUnifiedGroupOwner")] + [CmdletHelp("Removes owners from a particular Microsoft 365 Group", Category = CmdletHelpCategory.Graph, - OutputTypeLink = "https://docs.microsoft.com/graph/api/group-delete-owners", SupportedPlatform = CmdletSupportedPlatform.Online)] [CmdletExample( - Code = @"PS:> Remove-PnPUnifiedGroupOwner -Identity ""Project Team"" -Users ""john@contoso.onmicrosoft.com"",""jane@contoso.onmicrosoft.com""", + Code = @"PS:> Remove-PnPMicrosoft365GroupOwner -Identity ""Project Team"" -Users ""john@contoso.onmicrosoft.com"",""jane@contoso.onmicrosoft.com""", Remarks = @"Removes the provided two users as owners from the Microsoft 365 Group named ""Project Team""", SortOrder = 1)] + [CmdletRelatedLink(Text = "Documentation", Url = "https://docs.microsoft.com/graph/api/group-delete-owners")] [CmdletMicrosoftGraphApiPermission(MicrosoftGraphApiPermission.Group_ReadWrite_All | MicrosoftGraphApiPermission.Directory_ReadWrite_All)] - public class RemoveUnifiedGroupOwner : PnPGraphCmdlet + public class RemoveMicrosoft365GroupOwner : PnPGraphCmdlet { [Parameter(Mandatory = true, ValueFromPipeline = true, HelpMessage = "The Identity of the Microsoft 365 Group to remove owners from")] public UnifiedGroupPipeBind Identity; diff --git a/Commands/SharePointPnP.PowerShell.Commands.csproj b/Commands/SharePointPnP.PowerShell.Commands.csproj index 72ebe6852..6e022454c 100644 --- a/Commands/SharePointPnP.PowerShell.Commands.csproj +++ b/Commands/SharePointPnP.PowerShell.Commands.csproj @@ -624,11 +624,11 @@ - - - - - + + + + + @@ -673,7 +673,7 @@ - + From 151dff403f26749f19b53a9a69f2793535b846e8 Mon Sep 17 00:00:00 2001 From: Koen Zomers Date: Thu, 2 Jul 2020 00:27:00 +0200 Subject: [PATCH 5/5] Applied new AND permission attribute --- Commands/Graph/AddMicrosoft365GroupMember.cs | 3 +-- Commands/Graph/AddMicrosoft365GroupOwner.cs | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Commands/Graph/AddMicrosoft365GroupMember.cs b/Commands/Graph/AddMicrosoft365GroupMember.cs index 19cb591d9..d09e89ee1 100644 --- a/Commands/Graph/AddMicrosoft365GroupMember.cs +++ b/Commands/Graph/AddMicrosoft365GroupMember.cs @@ -22,8 +22,7 @@ namespace SharePointPnP.PowerShell.Commands.Graph Remarks = @"Sets the provided two users as the only members of the Microsoft 365 Group named ""Project Team"" by removing any current existing members first", SortOrder = 2)] [CmdletRelatedLink(Text = "Documentation", Url = "https://docs.microsoft.com/graph/api/group-post-members")] - [CmdletMicrosoftGraphApiPermission(MicrosoftGraphApiPermission.User_ReadWrite_All)] - [CmdletMicrosoftGraphApiPermission(MicrosoftGraphApiPermission.Group_ReadWrite_All)] + [CmdletMicrosoftGraphApiPermission(MicrosoftGraphApiPermission.None, MicrosoftGraphApiPermission.User_ReadWrite_All | MicrosoftGraphApiPermission.Group_ReadWrite_All)] public class AddMicrosoft365GroupMember : PnPGraphCmdlet { [Parameter(Mandatory = true, ValueFromPipeline = true, HelpMessage = "The Identity of the Microsoft 365 Group to add members to")] diff --git a/Commands/Graph/AddMicrosoft365GroupOwner.cs b/Commands/Graph/AddMicrosoft365GroupOwner.cs index f64975bd6..2ba3cc26c 100644 --- a/Commands/Graph/AddMicrosoft365GroupOwner.cs +++ b/Commands/Graph/AddMicrosoft365GroupOwner.cs @@ -23,8 +23,7 @@ namespace SharePointPnP.PowerShell.Commands.Graph Remarks = @"Sets the provided two users as the only owners of the Microsoft 365 Group named ""Project Team"" by removing any current existing owners first", SortOrder = 2)] [CmdletRelatedLink(Text = "Documentation", Url = "https://docs.microsoft.com/graph/api/group-post-owners")] - [CmdletMicrosoftGraphApiPermission(MicrosoftGraphApiPermission.User_ReadWrite_All)] - [CmdletMicrosoftGraphApiPermission(MicrosoftGraphApiPermission.Group_ReadWrite_All)] + [CmdletMicrosoftGraphApiPermission(MicrosoftGraphApiPermission.None, MicrosoftGraphApiPermission.User_ReadWrite_All | MicrosoftGraphApiPermission.Group_ReadWrite_All)] public class AddMicrosoft365GroupOwner : PnPGraphCmdlet { [Parameter(Mandatory = true, ValueFromPipeline = true, HelpMessage = "The Identity of the Microsoft 365 Group to add owners to")]