diff --git a/CHANGELOG.md b/CHANGELOG.md index 0dc08bd64..e04935577 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Fix `Register-PnPEntraIdApp` Allow to use CER file instead of PFX [#5129](https://github.com/pnp/powershell/issues/5129) ### Removed +- Removed `-RemoveExisting` parameter from `Add-PnPAzureADGroupMember`, `Add-PnPAzureADGroupOwner`, `Add-PnPMicrosoft365GroupMember` and `Add-PnPMicrosoft365GroupOwner` cmdlets. It was never really implemented and without function. [#5153](https://github.com/pnp/powershell/pull/5153) ### Contributors @@ -71,6 +72,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Ali Robertson [alirobe] - Christian Veenhuis [ChVeen] - James Epp [jamesaepp] +- Sven Boll [svenboll] ## [3.1.0] diff --git a/documentation/Add-PnPAzureADGroupMember.md b/documentation/Add-PnPAzureADGroupMember.md index 6ec3bf6cb..9b292ae46 100644 --- a/documentation/Add-PnPAzureADGroupMember.md +++ b/documentation/Add-PnPAzureADGroupMember.md @@ -20,12 +20,12 @@ Adds members to a particular Azure Active Directory Group. This can be a securit ## SYNTAX ```powershell -Add-PnPAzureADGroupMember -Identity -Users [-RemoveExisting] [-Connection ] +Add-PnPAzureADGroupMember -Identity -Users [-Connection ] ``` ## DESCRIPTION -Allows to add users to Azure Active Directory Group. This can be a security, distribution or Microsoft 365 group. By specifying `-RemoveExisting` option it is possible to first clear the group of all existing members. +Allows to add users to Azure Active Directory Group. This can be a security, distribution or Microsoft 365 group. ## EXAMPLES @@ -38,13 +38,6 @@ Adds the provided two users as additional members to the Azure Active Directory ### EXAMPLE 2 ```powershell -Add-PnPAzureADGroupMember -Identity "Project Team" -Users "john@contoso.onmicrosoft.com","jane@contoso.onmicrosoft.com" -RemoveExisting -``` - -Sets the provided two users as the only members of the Azure Active Directory group named "Project Team" by removing any current existing members first. - -### EXAMPLE 3 -```powershell Add-PnPAzureADGroupMember -Identity "Project Team" -Users "125eaa87-7b54-41fd-b30f-2adfa68c4afe" ``` @@ -79,20 +72,6 @@ Accept pipeline input: True (ByValue) Accept wildcard characters: False ``` -### -RemoveExisting -If provided, all existing members will be removed and only those provided through Users will become members. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - ### -Users The UPN(s) of the user(s) to add to the Azure Active Directory group as a member. diff --git a/documentation/Add-PnPAzureADGroupOwner.md b/documentation/Add-PnPAzureADGroupOwner.md index f7361a6f4..32b416bfb 100644 --- a/documentation/Add-PnPAzureADGroupOwner.md +++ b/documentation/Add-PnPAzureADGroupOwner.md @@ -20,12 +20,12 @@ Adds users to the owners of an Azure Active Directory group. This can be a secur ## SYNTAX ```powershell -Add-PnPAzureADGroupOwner -Identity -Users [-RemoveExisting] [-Connection ] +Add-PnPAzureADGroupOwner -Identity -Users [-Connection ] ``` ## DESCRIPTION -Allows to add users to owners of an Azure Active Directory Group. This can be a security, distribution or Microsoft 365 group. By specifying `-RemoveExisting` option it is possible to first clear the group of all existing members. +Allows to add users to owners of an Azure Active Directory Group. This can be a security, distribution or Microsoft 365 group. ## EXAMPLES @@ -38,13 +38,6 @@ Adds the provided two users as additional owners to the Azure Active Directory g ### EXAMPLE 2 ```powershell -Add-PnPAzureADGroupOwner -Identity "Project Team" -Users "john@contoso.onmicrosoft.com","jane@contoso.onmicrosoft.com" -RemoveExisting -``` - -Sets the provided two users as the only owners of the Azure Active Directory group named "Project Team" by removing any current existing members first. - -### EXAMPLE 3 -```powershell Add-PnPAzureADGroupOwner -Identity "Project Team" -Users "125eaa87-7b54-41fd-b30f-2adfa68c4afe" ``` @@ -79,20 +72,6 @@ Accept pipeline input: True (ByValue) Accept wildcard characters: False ``` -### -RemoveExisting -If provided, all existing members will be removed and only those provided through Users will become members. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - ### -Users The UPN(s) of the user(s) to add to the Azure Active Directory group as a member. diff --git a/documentation/Add-PnPMicrosoft365GroupMember.md b/documentation/Add-PnPMicrosoft365GroupMember.md index 015696fe9..d5650059e 100644 --- a/documentation/Add-PnPMicrosoft365GroupMember.md +++ b/documentation/Add-PnPMicrosoft365GroupMember.md @@ -20,7 +20,7 @@ Adds members to a particular Microsoft 365 Group. ## SYNTAX ```powershell -Add-PnPMicrosoft365GroupMember -Identity -Users [-RemoveExisting] [-Connection ] +Add-PnPMicrosoft365GroupMember -Identity -Users [-Connection ] ``` ## DESCRIPTION @@ -36,13 +36,6 @@ Add-PnPMicrosoft365GroupMember -Identity "Project Team" -Users "john@contoso.onm Adds the provided two users as additional members to the Microsoft 365 Group named "Project Team". -### EXAMPLE 2 -```powershell -Add-PnPMicrosoft365GroupMember -Identity "Project Team" -Users "john@contoso.onmicrosoft.com","jane@contoso.onmicrosoft.com" -RemoveExisting -``` - -Sets the provided two users as the only members of the Microsoft 365 Group named "Project Team" by removing any current existing members first. - ## PARAMETERS ### -Connection @@ -73,20 +66,6 @@ Accept pipeline input: True (ByValue) Accept wildcard characters: False ``` -### -RemoveExisting -If provided, all existing members will be removed and only those provided through Users will become members. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - ### -Users The UPN(s) of the user(s) to add to the Microsoft 365 Group as a member. diff --git a/documentation/Add-PnPMicrosoft365GroupOwner.md b/documentation/Add-PnPMicrosoft365GroupOwner.md index b70eb1d87..8960891c2 100644 --- a/documentation/Add-PnPMicrosoft365GroupOwner.md +++ b/documentation/Add-PnPMicrosoft365GroupOwner.md @@ -20,7 +20,7 @@ Adds users to a Microsoft 365 Group as Owners. ## SYNTAX ```powershell -Add-PnPMicrosoft365GroupOwner -Identity -Users [-RemoveExisting] [-Connection ] +Add-PnPMicrosoft365GroupOwner -Identity -Users [-Connection ] ``` ## DESCRIPTION @@ -36,13 +36,6 @@ Add-PnPMicrosoft365GroupOwner -Identity "Project Team" -Users "john@contoso.onmi Adds the provided two users as additional owners to the Microsoft 365 Group named "Project Team". -### EXAMPLE 2 -```powershell -Add-PnPMicrosoft365GroupOwner -Identity "Project Team" -Users "john@contoso.onmicrosoft.com","jane@contoso.onmicrosoft.com" -RemoveExisting -``` - -Sets the provided two users as the only owners of the Microsoft 365 Group named "Project Team" by removing any current existing members first. - ## PARAMETERS ### -Connection @@ -73,20 +66,6 @@ Accept pipeline input: True (ByValue) Accept wildcard characters: False ``` -### -RemoveExisting -If provided, all existing owners will be removed and only those provided through Users parameter will become owners. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - ### -Users The UPN(s) of the user(s) to add to the Microsoft 365 Group as an owner. diff --git a/src/Commands/AzureAD/AddAzureADGroupMember.cs b/src/Commands/AzureAD/AddAzureADGroupMember.cs index 759746c8a..af7e3253e 100644 --- a/src/Commands/AzureAD/AddAzureADGroupMember.cs +++ b/src/Commands/AzureAD/AddAzureADGroupMember.cs @@ -20,9 +20,6 @@ public class AddAzureADGroupMember : PnPGraphCmdlet [Parameter(Mandatory = true)] public string[] Users; - [Parameter(Mandatory = false)] - public SwitchParameter RemoveExisting; - protected override void ExecuteCmdlet() { Group group = null; @@ -39,14 +36,14 @@ protected override void ExecuteCmdlet() if (userArray.Length > 0) { - Microsoft365GroupsUtility.AddMembers(GraphRequestHelper, new Guid(group.Id), userArray, RemoveExisting.ToBool()); + Microsoft365GroupsUtility.AddMembers(GraphRequestHelper, new Guid(group.Id), userArray); } var secGroups = Users.Where(x => Guid.TryParse(x, out emptyGuid)).Select(x => emptyGuid).ToArray(); if (secGroups.Length > 0) { - Microsoft365GroupsUtility.AddDirectoryMembers(GraphRequestHelper, new Guid(group.Id), secGroups, RemoveExisting.ToBool()); + Microsoft365GroupsUtility.AddDirectoryMembers(GraphRequestHelper, new Guid(group.Id), secGroups); } } } diff --git a/src/Commands/AzureAD/AddAzureADGroupOwner.cs b/src/Commands/AzureAD/AddAzureADGroupOwner.cs index 937945d6f..2b8578093 100644 --- a/src/Commands/AzureAD/AddAzureADGroupOwner.cs +++ b/src/Commands/AzureAD/AddAzureADGroupOwner.cs @@ -20,9 +20,6 @@ public class AddAzureAdGroupOwner : PnPGraphCmdlet [Parameter(Mandatory = true)] public string[] Users; - [Parameter(Mandatory = false)] - public SwitchParameter RemoveExisting; - protected override void ExecuteCmdlet() { Group group = null; @@ -41,14 +38,14 @@ protected override void ExecuteCmdlet() if (userArray.Length > 0) { - Microsoft365GroupsUtility.AddOwners(GraphRequestHelper, new System.Guid(group.Id), userArray, RemoveExisting.ToBool()); + Microsoft365GroupsUtility.AddOwners(GraphRequestHelper, new System.Guid(group.Id), userArray); } var secGroups = Users.Where(x => Guid.TryParse(x, out emptyGuid)).Select(x => emptyGuid).ToArray(); if (secGroups.Length > 0) { - Microsoft365GroupsUtility.AddDirectoryOwners(GraphRequestHelper, new System.Guid(group.Id), secGroups, RemoveExisting.ToBool()); + Microsoft365GroupsUtility.AddDirectoryOwners(GraphRequestHelper, new System.Guid(group.Id), secGroups); } } } diff --git a/src/Commands/Microsoft365Groups/AddMicrosoft365GroupMember.cs b/src/Commands/Microsoft365Groups/AddMicrosoft365GroupMember.cs index cd79de036..60c1e1762 100644 --- a/src/Commands/Microsoft365Groups/AddMicrosoft365GroupMember.cs +++ b/src/Commands/Microsoft365Groups/AddMicrosoft365GroupMember.cs @@ -16,12 +16,9 @@ public class AddMicrosoft365GroupMember : PnPGraphCmdlet [Parameter(Mandatory = true)] public string[] Users; - [Parameter(Mandatory = false)] - public SwitchParameter RemoveExisting; - protected override void ExecuteCmdlet() { - Microsoft365GroupsUtility.AddMembers(GraphRequestHelper, Identity.GetGroupId(GraphRequestHelper), Users, RemoveExisting); + Microsoft365GroupsUtility.AddMembers(GraphRequestHelper, Identity.GetGroupId(GraphRequestHelper), Users); } } } \ No newline at end of file diff --git a/src/Commands/Microsoft365Groups/AddMicrosoft365GroupOwner.cs b/src/Commands/Microsoft365Groups/AddMicrosoft365GroupOwner.cs index 98f6ec4a3..e5fa0107c 100644 --- a/src/Commands/Microsoft365Groups/AddMicrosoft365GroupOwner.cs +++ b/src/Commands/Microsoft365Groups/AddMicrosoft365GroupOwner.cs @@ -16,12 +16,9 @@ public class AddMicrosoft365GroupOwner : PnPGraphCmdlet [Parameter(Mandatory = true)] public string[] Users; - [Parameter(Mandatory = false)] - public SwitchParameter RemoveExisting; - protected override void ExecuteCmdlet() { - Microsoft365GroupsUtility.AddOwners(GraphRequestHelper, Identity.GetGroupId(GraphRequestHelper), Users, RemoveExisting); + Microsoft365GroupsUtility.AddOwners(GraphRequestHelper, Identity.GetGroupId(GraphRequestHelper), Users); } } } \ No newline at end of file diff --git a/src/Commands/Utilities/Microsoft365GroupsUtility.cs b/src/Commands/Utilities/Microsoft365GroupsUtility.cs index 648897129..cf53927cb 100644 --- a/src/Commands/Utilities/Microsoft365GroupsUtility.cs +++ b/src/Commands/Utilities/Microsoft365GroupsUtility.cs @@ -289,24 +289,24 @@ internal static void PermanentlyDeleteDeletedGroup(ApiRequestHelper requestHelpe requestHelper.Delete($"v1.0/directory/deleteditems/microsoft.graph.group/{groupId}"); } - internal static void AddOwners(ApiRequestHelper requestHelper, Guid groupId, string[] users, bool removeExisting) + internal static void AddOwners(ApiRequestHelper requestHelper, Guid groupId, string[] users) { - AddUsersToGroup(requestHelper, "owners", groupId, users, removeExisting); + AddUsersToGroup(requestHelper, "owners", groupId, users); } - internal static void AddDirectoryOwners(ApiRequestHelper requestHelper, Guid groupId, Guid[] users, bool removeExisting) + internal static void AddDirectoryOwners(ApiRequestHelper requestHelper, Guid groupId, Guid[] users) { - AddDirectoryObjectsToGroup(requestHelper, "owners", groupId, users, removeExisting); + AddDirectoryObjectsToGroup(requestHelper, "owners", groupId, users); } - internal static void AddMembers(ApiRequestHelper requestHelper, Guid groupId, string[] users, bool removeExisting) + internal static void AddMembers(ApiRequestHelper requestHelper, Guid groupId, string[] users) { - AddUsersToGroup(requestHelper, "members", groupId, users, removeExisting); + AddUsersToGroup(requestHelper, "members", groupId, users); } - internal static void AddDirectoryMembers(ApiRequestHelper requestHelper, Guid groupId, Guid[] users, bool removeExisting) + internal static void AddDirectoryMembers(ApiRequestHelper requestHelper, Guid groupId, Guid[] users) { - AddDirectoryObjectsToGroup(requestHelper, "members", groupId, users, removeExisting); + AddDirectoryObjectsToGroup(requestHelper, "members", groupId, users); } internal static string GetUserGraphUrlForUPN(string upn) @@ -318,7 +318,7 @@ internal static string GetUserGraphUrlForUPN(string upn) return $"users/{escapedUpn}"; } - private static void AddUsersToGroup(ApiRequestHelper requestHelper, string groupName, Guid groupId, string[] users, bool removeExisting) + private static void AddUsersToGroup(ApiRequestHelper requestHelper, string groupName, Guid groupId, string[] users) { foreach (var user in users) { @@ -338,7 +338,7 @@ private static void AddUsersToGroup(ApiRequestHelper requestHelper, string group } } - private static void AddDirectoryObjectsToGroup(ApiRequestHelper requestHelper, string groupName, Guid groupId, Guid[] directoryObjects, bool removeExisting) + private static void AddDirectoryObjectsToGroup(ApiRequestHelper requestHelper, string groupName, Guid groupId, Guid[] directoryObjects) { foreach (var dirObject in directoryObjects) { @@ -440,7 +440,7 @@ internal static void UpdateOwners(ApiRequestHelper requestHelper, Guid groupId, { if (existingOwners.FirstOrDefault(o => o.UserPrincipalName == owner) == null) { - AddOwners(requestHelper, groupId, new string[] { owner }, false); + AddOwners(requestHelper, groupId, new string[] { owner }); } } foreach (var existingOwner in existingOwners) @@ -459,7 +459,7 @@ internal static void UpdateMembersAsync(ApiRequestHelper requestHelper, Guid gro { if (existingMembers.FirstOrDefault(o => o.UserPrincipalName == member) == null) { - AddMembers(requestHelper, groupId, new string[] { member }, false); + AddMembers(requestHelper, groupId, new string[] { member }); } } foreach (var existingMember in existingMembers)