Created
August 12, 2017 09:13
-
-
Save aflyen/b62e5663df5e42d59dd75c93866700ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Configuration | |
$SiteUrl = "https://TENANTID.sharepoint.com" | |
$TermGroupName = "Contoso" | |
$TermSetName = "Document Types" | |
$TermName = "Reports" | |
$TermLcid = 1033 | |
$TermGuid = "2bdb40fd-02e4-4604-914e-9f8012685be0" | |
# Get correct termset | |
Connect-PnPOnline -Url $SiteUrl -Credentials $GlobalCredentialsId | |
$Context = Get-PnPContext | |
$TaxonomySession = [Microsoft.SharePoint.Client.Taxonomy.TaxonomySession]::GetTaxonomySession($Context) | |
$TermStores = $TaxonomySession.TermStores | |
$Context.Load($TaxonomySession) | |
$Context.Load($TermStores) | |
Execute-PnPQuery | |
$TermStore = $TermStores[0] | |
$Context.Load($TermStore) | |
Execute-PnPQuery | |
$Group = $TermStore.Groups.GetByName($TermGroupName) | |
$TermSet = $Group.TermSets.GetByName($TermSetName) | |
$Context.Load($Group) | |
$Context.Load($TermSet) | |
Execute-PnPQuery | |
# Create new term | |
$Term = $TermSet.CreateTerm($TermName, $TermLcid, [System.Guid]::Parse($TermGuid)) | |
$Context.Load($Term) | |
Execute-PnPQuery | |
Disconnect-PnPOnline |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment