Skip to content
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Added `Add-PnPFileSensitivityLabel` which allows for assigning sensitivity labels to SharePoint files [#4538](https://github.com/pnp/powershell/pull/4538)
- Added `-CanSyncHubSitePermissions` parameter to `Set-PnPSite` cmdlet to set value of allowing syncing hub site permissions to this associated site.
- Added `Get-PnPProfileCardProperty`, `New-PnPProfileCardProperty` and `Remove-PnPProfileCardProperty` cmdlets to manage showing additional properties on the Microsoft 365 user profile [#4548](https://github.com/pnp/powershell/pull/4548)
- Added `-Contributors` and `-Managers` parameters to `New-PnPTermGroup` and `Set-PnPTermGroup` cmdlets.

### Changed

Expand Down
39 changes: 38 additions & 1 deletion documentation/New-PnPTermGroup.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Creates a taxonomy term group

```powershell
New-PnPTermGroup -Name <String> [-Id <Guid>] [-Description <String>]
[-TermStore <PnP.PowerShell.Commands.Base.PipeBinds.GenericObjectNameIdPipeBind`1[Microsoft.SharePoint.Client.Taxonomy.TermStore]>]
[-TermStore <PnP.PowerShell.Commands.Base.PipeBinds.GenericObjectNameIdPipeBind`1[Microsoft.SharePoint.Client.Taxonomy.TermStore]>] [-Contributors <string []>] [-Managers <string []>]
[-Connection <PnPConnection>]
```

Expand All @@ -33,6 +33,13 @@ New-PnPTermGroup -GroupName "Countries"

Creates a new taxonomy term group named "Countries"

### EXAMPLE 2
```powershell
New-PnPTermGroup -GroupName "Countries" -Contributors @("i:0#.f|membership|[email protected]","i:0#.f|membership|[email protected]") -Managers @("i:0#.f|membership|[email protected]","i:0#.f|membership|[email protected]")
```

Creates a new taxonomy term group named "Countries" and sets the users as contributors and managers of the term group. **The user names for contributors and managers need to be encoded claim for the specified login names.**

## PARAMETERS

### -Connection
Expand Down Expand Up @@ -108,6 +115,36 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -Managers
The manager of the term group who can create/edit term sets in the group as well as add/remove contributors. **The user names for managers need to be encoded claim for the specified login names.**

```yaml
Type: string[]
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Contributors
The contributor to the term group who can create/edit term sets in the group. **The user names for contributors need to be encoded claim for the specified login names.**

```yaml
Type: string[]
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

## RELATED LINKS

[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp)
Expand Down
40 changes: 38 additions & 2 deletions documentation/Set-PnPTermGroup.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Updates an existing term group.

```powershell
Set-PnPTermGroup -Identity <TaxonomyTermGroupPipeBind> [-Name <String>] [-Description <String>]
[-TermStore <TaxonomyTermStorePipeBind>] [-Connection <PnPConnection>]
[-TermStore <TaxonomyTermStorePipeBind>] [-Connection <PnPConnection>] [-Contributors <string []>] [-Managers <string []>]
```

## DESCRIPTION
Expand All @@ -31,8 +31,14 @@ Set-PnPTermGroup -Identity "Departments" -Name "Company Units"

Renames the Departments termgroup to "Company Units".

## PARAMETERS
### Example 2
```powershell
Set-PnPTermGroup -Identity "Departments" -Name "Company Units" -Contributors @("i:0#.f|membership|[email protected]","i:0#.f|membership|[email protected]") -Managers @("i:0#.f|membership|[email protected]","i:0#.f|membership|[email protected]")
```

Renames the Departments termgroup to "Company Units" and adds contributors and managers of the term group. **The user names for contributors and managers need to be encoded claim for the specified login names.**

## PARAMETERS

### -Description
Optional description of the term group.
Expand Down Expand Up @@ -109,6 +115,36 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -Managers
The manager of the term group who can create/edit term sets in the group as well as add/remove contributors. **The user names for managers need to be encoded claim for the specified login names.**

```yaml
Type: string[]
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Contributors
The contributor to the term group who can create/edit term sets in the group. **The user names for contributors need to be encoded claim for the specified login names.**

```yaml
Type: string[]
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```


## RELATED LINKS

Expand Down
41 changes: 37 additions & 4 deletions src/Commands/Taxonomy/NewTermGroup.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using System;
using System.Management.Automation;
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client.Taxonomy;

using PnP.PowerShell.Commands.Base.PipeBinds;
using System;
using System.Management.Automation;

namespace PnP.PowerShell.Commands.Taxonomy
{
Expand All @@ -25,6 +24,12 @@ public class NewTermGroup : PnPSharePointCmdlet
[Alias("TermStoreName")]
public TaxonomyTermStorePipeBind TermStore;

[Parameter(Mandatory = false)]
public string[] Contributors;

[Parameter(Mandatory = false)]
public string[] Managers;

protected override void ExecuteCmdlet()
{
var taxonomySession = TaxonomySession.GetTaxonomySession(ClientContext);
Expand All @@ -40,6 +45,34 @@ protected override void ExecuteCmdlet()
}
// Create Group
var group = termStore.CreateTermGroup(Name, Id, Description);
bool updateRequired = false;
if (Contributors != null && Contributors.Length > 0)
{
foreach (var contributor in Contributors)
{
group.AddContributor(contributor);
}
updateRequired = true;
}
if (Managers != null && Managers.Length > 0)
{
foreach (var manager in Managers)
{
group.AddGroupManager(manager);
}
updateRequired = true;
}

if (updateRequired)
{
termStore.CommitAll();
ClientContext.Load(group, group => group.GroupManagerPrincipalNames, group => group.ContributorPrincipalNames, group => group.Name, group => group.Description, group => group.Id);
ClientContext.Load(termStore);
ClientContext.ExecuteQueryRetry();

taxonomySession.UpdateCache();
taxonomySession.Context.ExecuteQueryRetry();
}

WriteObject(group);
}
Expand Down
27 changes: 27 additions & 0 deletions src/Commands/Taxonomy/SetTermGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ public class SetTermGroup : PnPSharePointCmdlet
[Parameter(Mandatory = false)]
public string Description { get; set; }

[Parameter(Mandatory = false)]
public string[] Contributors { get; set; }

[Parameter(Mandatory = false)]
public string[] Managers { get; set; }

protected override void ExecuteCmdlet()
{
var taxonomySession = TaxonomySession.GetTaxonomySession(ClientContext);
Expand Down Expand Up @@ -61,10 +67,31 @@ protected override void ExecuteCmdlet()
group.Description = Description;
updateRequired = true;
}
if (Contributors != null && Contributors.Length > 0)
{
foreach (var contributor in Contributors)
{
group.AddContributor(contributor);
}
updateRequired = true;
}
if (Managers != null && Managers.Length > 0)
{
foreach (var manager in Managers)
{
group.AddGroupManager(manager);
}
updateRequired = true;
}
if (updateRequired)
{
termStore.CommitAll();
ClientContext.Load(group, group => group.GroupManagerPrincipalNames, group => group.ContributorPrincipalNames, group => group.Name, group => group.Description, group => group.Id);
ClientContext.Load(termStore);
ClientContext.ExecuteQueryRetry();

taxonomySession.UpdateCache();
taxonomySession.Context.ExecuteQueryRetry();
}
WriteObject(group);
}
Expand Down
Loading