Hi,
How to update managed metadata column for all file in document library using powershell?
Any help on it.
Thanks & REgards
Poomani Sankaran
Technology Tips and News
Hi,
How to update managed metadata column for all file in document library using powershell?
Any help on it.
Thanks & REgards
Poomani Sankaran
Hi TenPart,
Yes.. In the document library i have created many folders and sub folders with files.
But all the files in same meta data tag only. I need to change from one to another.
$web = Get-SPWeb http://portal.sharepoint.com $list = $web.Lists["LargeList"] $query = New-Object Microsoft.SharePoint.SPQuery $query.ViewAttributes = "Scope='Recursive'"; $query.RowLimit = 2000 $caml = '<Where><BeginsWith><FieldRef Name="Title" /><Value Type="Text">Item 1</Value></BeginsWith></Where>' + '<OrderBy Override="TRUE"><FieldRef Name="ID"/></OrderBy>' $query.Query = $caml do { $listItems = $list.GetItems($query) $spQuery.ListItemCollectionPosition = $listItems.ListItemCollectionPosition foreach($item in $listItems) { #Cast to SPListItem to avoid ambiguous overload error $spItem = [Microsoft.SharePoint.SPListItem]$item; #Get the taxonomy field for the list item $taxField = [Microsoft.SharePoint.Taxonomy.TaxonomyField]$spItem.Fields["Project"] #Set the field's value using the term $taxField.SetFieldValue($spItem,$term) $spItem.Update() } } while ($spQuery.ListItemCollectionPosition -ne $null)This will do what you want. Change it to suit your environment.
Hi TanPart,
I have changed the code which you have give in order to get the files from SharePoint 2010 Foundation Document Library.But i am getting below error in powershell.
Property 'ListItemCollectionPosition' cannot be found on this object; make sure it exists and is settable.
Could you tell me which is the issues in it?
See the code below.
$web = Get-SPWeb http://ntmoss2010:9090/Site
$list = $web.Lists["DocLib"]
$query = New-Object Microsoft.SharePoint.SPQuery
$query.ViewAttributes = "Scope='Recursive'";
$query.RowLimit = 2000
$caml = '<Where><Contains><FieldRef Name="Title" /><Value Type="Text">Process Documents/Delivery</Value></Contains></Where>' +
'<OrderBy Override="TRUE"><FieldRef Name="ID"/></OrderBy>'
$query.Query = $caml
do
{
$listItems = $list.GetItems($query)
$spQuery.ListItemCollectionPosition = $listItems.ListItemCollectionPosition
foreach($item in $listItems)
{
#Cast to SPListItem to avoid ambiguous overload error
$spItem = [Microsoft.SharePoint.SPListItem]$item;
Write-Host $spItem.Title
}
}
while ($spQuery.ListItemCollectionPosition -ne $null)
Thanks & Regards
Poomani Sankaran