Quantcast
Channel: SharePoint – SharePoint Rider
Viewing all articles
Browse latest Browse all 55

How to update taxonomy hidden field using PowerShell?

$
0
0

Continuation to How to use taxonomy hidden field? – (http://sprider.org/2014/09/18/894/) Article

Example PowerShell script to update taxonomy(MMD) hidden field

Add-PSSnapin Microsoft.Sharepoint.Powershell

$sourceWebURL = “http://<Site URL>
$sourceListName = “<List Name>“

[Microsoft.SharePoint.SPSecurity]::RunWithElevatedPrivileges({

$spSourceWeb = Get-SPWeb $sourceWebURL
$spSourceList = $spSourceWeb.Lists[$sourceListName]

$spQuery = New-Object Microsoft.SharePoint.SPQuery
$caml = ‘<Where><Geq><FieldRef Name=”ID” /><Value Type=”Text”>0</Value></Geq></Where>’
$spQuery.Query = $caml
$spSourceItems = $spSourceList.GetItems($spQuery)

$spSourceWeb.AllowUnsafeUpdates = “true”;

foreach($item in $spSourceItems)
{
$item[taxonomyFieldObject.TextField] = “Term Value1|GUID1”; # Based on how you have configured the MMD column, supply the input here. To check the hidden value, we can use sharepoint manager complex tool
$item.Update()
}
$spSourceWeb.AllowUnsafeUpdates = “false”;
$spSourceWeb.Dispose();

});


Filed under: Powershell

Viewing all articles
Browse latest Browse all 55

Trending Articles