Add-PSSnapin Microsoft.SharePoint.Powershell
$site = 'Site URL’
$fieldName = 'Countries'
$web = Get-SPWeb $site
$mmsServiceName = "Managed Metadata Service"
$taxonomySite = Get-SPSite $site
$web= $taxonomySite.OpenWeb()
$taxSession = New-Object Microsoft.SharePoint.Taxonomy.TaxonomySession($taxonomySite)
$termStore = $taxSession.TermStores[$mmsServiceName]
$field = $web.Fields.GetFieldByInternalName('Countries')
$defaultValue=$field.DefaultValue
foreach($list in $web.Lists)
{
if( $list.Fields.ContainsField("Countries") -eq $true)
{
write-host $item["Title"]
$spItem = [Microsoft.SharePoint.SPListItem]$item;
$taxField = [Microsoft.SharePoint.Taxonomy.TaxonomyField]$spItem.Fields["Countries"]
$item["Countries"] = $defaultValue;
$item.Update();
break;
}
}
No comments:
Post a Comment