Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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--
}
share|improve this question
add comment

1 Answer 1

up vote 0 down vote accepted

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-- 
} 
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.