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

Resubmit of PR2474 #2475

Merged
merged 9 commits into from
Feb 9, 2020
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Added ability to use `Set-PnPRequestAccessEmails` with `-Disabled` to disable requesting access to a site and `-Disabled:$false` to set the access requests to be sent to the default owners of the site [PR #2456](https://github.com/SharePoint/PnP-PowerShell/pull/2456)
- Added `Get-PnPSiteScriptFromList` and `Get-PnPSiteScriptFromWeb` commands which allow generation of Site Script JSON based off of existing lists or an entire site [PR # 2459](https://github.com/SharePoint/PnP-PowerShell/pull/2459)
- Added `-Aggregations` argument to `Add-PnPView` and `Set-PnPView` to allow for creating a Totals count in a view [PR #2257](https://github.com/SharePoint/PnP-PowerShell/pull/2257)
- Added `New-PnPTermLabel` to add a localized label to an existing taxonomy term [PR #2475](https://github.com/SharePoint/PnP-PowerShell/pull/2475)

### Changed
- Optimized Invoke-PnPSearchQuery when using the -All parameter to ensure all results are returned by ordering on IndexDocId, and changed the default ClientType to 'PnP'
Expand All @@ -30,6 +31,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- Gautam Sheth [gautamdsheth]
- Craig Hair [MacsInSpace]
- Dan Cecil [danielcecil]
- Markus Hanisch [Markus-Hanisch]

## [3.17.2001.2]

Expand Down
1 change: 1 addition & 0 deletions Commands/SharePointPnP.PowerShell.Commands.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,7 @@
<Compile Include="Site\GetRoleDefinition.cs" />
<Compile Include="Site\RemoveRoleDefinition.cs" />
<Compile Include="Site\TestOffice365GroupAliasIsUsed.cs" />
<Compile Include="Taxonomy\NewTermLabel.cs" />
<Compile Include="UserProfiles\GetUPABulkImportStatus.cs" />
<Compile Include="UserProfiles\NewUPABulkImportJob.cs" />
<Compile Include="Utilities\BrowserHelper.cs" />
Expand Down
7 changes: 6 additions & 1 deletion Commands/Taxonomy/GetTerm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ namespace SharePointPnP.PowerShell.Commands.Taxonomy
[CmdletExample(
Code = @"PS:> Get-PnPTerm -Identity ""Small Finance"" -TermSet ""Departments"" -TermGroup ""Corporate"" -Recursive",
Remarks = @"Returns the term named ""Small Finance"", from the ""Departments"" termset in a term group called ""Corporate"" from the site collection termstore even if it's a subterm below ""Finance""",
SortOrder = 2)]
SortOrder = 3)]
[CmdletExample(
Code = @"PS:> $term = Get-PnPTerm -Identity ""Small Finance"" -TermSet ""Departments"" -TermGroup ""Corporate"" -Include Labels
PS:> $term.Labels",
Remarks = @"Returns all the localized labels for the term named ""Small Finance"", from the ""Departments"" termset in a term group called ""Corporate""",
SortOrder = 4)]
public class GetTerm : PnPRetrievalsCmdlet<Term>
{
private const string ParameterSet_TERM = "By Term Id";
Expand Down
13 changes: 4 additions & 9 deletions Commands/Taxonomy/NewTerm.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Management.Automation;
using System.Runtime.InteropServices;
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client.Taxonomy;
using SharePointPnP.PowerShell.CmdletHelpAttributes;
Expand All @@ -15,7 +13,8 @@ namespace SharePointPnP.PowerShell.Commands.Taxonomy
[CmdletHelp(@"Creates a taxonomy term",
Category = CmdletHelpCategory.Taxonomy,
OutputType = typeof(Term),
OutputTypeLink = "https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.taxonomy.term.aspx")]
OutputTypeLink = "https://docs.microsoft.com/en-us/previous-versions/office/sharepoint-csom/jj166573(v=office.15)",
SupportedPlatform = CmdletSupportedPlatform.All)]
[CmdletExample
(Code = @"PS:> New-PnPTerm -TermSet ""Departments"" -TermGroup ""Corporate"" -Name ""Finance""",
Remarks = @"Creates a new taxonomy term named ""Finance"" in the termset Departments which is located in the ""Corporate"" termgroup",
Expand All @@ -34,11 +33,9 @@ public class NewTerm : PnPCmdlet
[Parameter(Mandatory = true, ValueFromPipeline = true, Position = 0, HelpMessage = "The termset to add the term to.")]
public TaxonomyItemPipeBind<TermSet> TermSet;

[Parameter(Mandatory = true, ValueFromPipeline = true,
HelpMessage = "The termgroup to create the term in.")]
[Parameter(Mandatory = true, ValueFromPipeline = true, HelpMessage = "The termgroup to create the term in.")]
public TermGroupPipeBind TermGroup;


[Parameter(Mandatory = false, HelpMessage = "Descriptive text to help users understand the intended use of this term.")]
public string Description;

Expand All @@ -48,8 +45,7 @@ public class NewTerm : PnPCmdlet
[Parameter(Mandatory = false, HelpMessage = "Custom Properties")]
public Hashtable LocalCustomProperties;

[Parameter(Mandatory = false, ParameterSetName = ParameterAttribute.AllParameterSets,
HelpMessage = "Term store to check; if not specified the default term store is used.")]
[Parameter(Mandatory = false, ParameterSetName = ParameterAttribute.AllParameterSets, HelpMessage = "Term store to check; if not specified the default term store is used.")]
[Alias("TermStoreName")]
public GenericObjectNameIdPipeBind<TermStore> TermStore;

Expand Down Expand Up @@ -129,6 +125,5 @@ protected override void ExecuteCmdlet()
ClientContext.ExecuteQueryRetry();
WriteObject(term);
}

}
}
51 changes: 51 additions & 0 deletions Commands/Taxonomy/NewTermLabel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System;
using System.Management.Automation;
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client.Taxonomy;
using SharePointPnP.PowerShell.CmdletHelpAttributes;
using SharePointPnP.PowerShell.Commands.Base.PipeBinds;

namespace SharePointPnP.PowerShell.Commands.Taxonomy
{
[Cmdlet(VerbsCommon.New, "PnPTermLabel", SupportsShouldProcess = false)]
[CmdletHelp(@"Creates a localized label for a taxonomy term",
Category = CmdletHelpCategory.Taxonomy,
OutputType = typeof(Label),
OutputTypeLink = "https://docs.microsoft.com/en-us/dotnet/api/microsoft.sharepoint.taxonomy.label",
DetailedDescription = "Creates a localized label for a taxonomy term. Use Get-PnPTerm -Include Labels to request the current labels on a taxonomy term.",
SupportedPlatform = CmdletSupportedPlatform.All)]
[CmdletExample
(Code = @"PS:> New-PnPTermLabel -Name ""Finanzwesen"" -Lcid 1031 -Term (Get-PnPTerm -Identity ""Finance"" -TermSet ""Departments"" -TermGroup ""Corporate"")",
Remarks = @"Creates a new localized taxonomy label in German (LCID 1031) named ""Finanzwesen"" for the term ""Finance"" in the termset Departments which is located in the ""Corporate"" termgroup",
SortOrder = 1)]
[CmdletExample
(Code = @"PS:> Get-PnPTerm -Identity ""Finance"" -TermSet ""Departments"" -TermGroup ""Corporate"" | New-PnPTermLabel -Name ""Finanzwesen"" -Lcid 1031",
Remarks = @"Creates a new localized taxonomy label in German (LCID 1031) named ""Finanzwesen"" for the term ""Finance"" in the termset Departments which is located in the ""Corporate"" termgroup",
SortOrder = 2)]
public class NewTermLabel : PnPCmdlet
{
[Parameter(Mandatory = true, ValueFromPipeline = true, Position = 0, HelpMessage = "The term to add the localized label to")]
public TaxonomyItemPipeBind<Term> Term;

[Parameter(Mandatory = true, HelpMessage = "The localized name of the term")]
public string Name;

[Parameter(Mandatory = true, HelpMessage = "The locale id to use for the localized term")]
public int Lcid;

[Parameter(Mandatory = false, HelpMessage = "Makes this new label the default label", ParameterSetName = ParameterAttribute.AllParameterSets)]
public SwitchParameter IsDefault = true;

protected override void ExecuteCmdlet()
{
if (Term.Item == null)
{
throw new ArgumentException("You must pass in a Term instance to this command", nameof(Term));
}

var label = Term.Item.CreateLabel(Name, Lcid, IsDefault.IsPresent ? IsDefault.ToBool() : true);
ClientContext.ExecuteQueryRetry();
WriteObject(label);
}
}
}