Question

How do I set a metadata (say CustomerID or Skills) with PowerShell? I am trying to fill CustID. Edited. This is the working version of the final powershell code.

Here is the working code....

$siteURL="http://Server"
$docLib = "My Doc Lib"
$site=Get-SPSite $siteURL
$web=$site.RootWeb
$collFiles=$web.GetFolder($docLib).Files
$count=$collFiles.Count
while($count -ne 0)
{
$item = $collFiles[$count-1].Item
$DocSet = $item["Region"]
Write-Host "$DocSet is the doc set. $collFiles[$count-1].Name is name"
$collFiles[$count-1].MoveTo($siteURL + "/" + $docLib + "/" + $DocSet + "/"  + $collFiles[$count-1].Name, $true)                       
$count--
}
Was it helpful?

Solution

Here is the working code....

$siteURL="http://Server"
$docLib = "My Doc Lib" 
$site=Get-SPSite $siteURL 
$web=$site.RootWeb 
$collFiles=$web.GetFolder($docLib).Files 
$count=$collFiles.Count 

while($count -ne 0) 
{
 $item = $collFiles[$count-1].Item 
 $DocSet = $item["Region"]
 Write-Host "$DocSet is the doc set. $collFiles[$count-1].Name is name"
 $collFiles[$count-1].MoveTo($siteURL + "/" + $docLib + "/" + $DocSet + "/"  + $collFiles[$count-1].Name, $true)                       
$count-- 
} 
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top