Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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]

Expand Down
25 changes: 2 additions & 23 deletions documentation/Add-PnPAzureADGroupMember.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ Adds members to a particular Azure Active Directory Group. This can be a securit
## SYNTAX

```powershell
Add-PnPAzureADGroupMember -Identity <AzureADGroupPipeBind> -Users <String[]> [-RemoveExisting] [-Connection <PnPConnection>]
Add-PnPAzureADGroupMember -Identity <AzureADGroupPipeBind> -Users <String[]> [-Connection <PnPConnection>]
```

## 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

Expand All @@ -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"
```

Expand Down Expand Up @@ -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.

Expand Down
25 changes: 2 additions & 23 deletions documentation/Add-PnPAzureADGroupOwner.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <AzureADGroupPipeBind> -Users <String[]> [-RemoveExisting] [-Connection <PnPConnection>]
Add-PnPAzureADGroupOwner -Identity <AzureADGroupPipeBind> -Users <String[]> [-Connection <PnPConnection>]
```

## 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

Expand All @@ -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"
```

Expand Down Expand Up @@ -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.

Expand Down
23 changes: 1 addition & 22 deletions documentation/Add-PnPMicrosoft365GroupMember.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Adds members to a particular Microsoft 365 Group.
## SYNTAX

```powershell
Add-PnPMicrosoft365GroupMember -Identity <Microsoft365GroupPipeBind> -Users <String[]> [-RemoveExisting] [-Connection <PnPConnection>]
Add-PnPMicrosoft365GroupMember -Identity <Microsoft365GroupPipeBind> -Users <String[]> [-Connection <PnPConnection>]
```

## DESCRIPTION
Expand All @@ -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
Expand Down Expand Up @@ -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.

Expand Down
23 changes: 1 addition & 22 deletions documentation/Add-PnPMicrosoft365GroupOwner.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Adds users to a Microsoft 365 Group as Owners.
## SYNTAX

```powershell
Add-PnPMicrosoft365GroupOwner -Identity <Microsoft365GroupPipeBind> -Users <String[]> [-RemoveExisting] [-Connection <PnPConnection>]
Add-PnPMicrosoft365GroupOwner -Identity <Microsoft365GroupPipeBind> -Users <String[]> [-Connection <PnPConnection>]
```

## DESCRIPTION
Expand All @@ -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
Expand Down Expand Up @@ -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.

Expand Down
7 changes: 2 additions & 5 deletions src/Commands/AzureAD/AddAzureADGroupMember.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
}
}
Expand Down
7 changes: 2 additions & 5 deletions src/Commands/AzureAD/AddAzureADGroupOwner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
5 changes: 1 addition & 4 deletions src/Commands/Microsoft365Groups/AddMicrosoft365GroupOwner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
24 changes: 12 additions & 12 deletions src/Commands/Utilities/Microsoft365GroupsUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
{
Expand All @@ -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)
{
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down