Skip to content

Instantly share code, notes, and snippets.

@dmadelung
Last active May 15, 2018 20:35
Show Gist options
  • Save dmadelung/67e83c37e46c96db1c7913bae98d3fba to your computer and use it in GitHub Desktop.
Save dmadelung/67e83c37e46c96db1c7913bae98d3fba to your computer and use it in GitHub Desktop.
$terms = @()
#set terms
$terms = "Term1","Term2"
#set mm field
$mmfield = 'MM'
#get term info
$tg = Get-PnPTermGroup -Identity "Site Collection - drewmadelung.sharepoint.com"
$ts = Get-PnPTermSet -TermGroup $tg -Identity "TermSet"
$var = @{
$mmfield = @()
}
#add terms to table
$terms.ForEach({
$t = Get-PnPTerm -Identity $_ -TermGroup $tg -TermSet $ts
foreach($key in $($var.keys)){
if($key -eq $mmfield){
$var[$key] += $t.Id.ToString()
}
}
})
#set item
Set-PnPListItem -List $list -Identity 4 -Values $var -SystemUpdate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment