Need to find out the document set name from a field name called "Region". I need to set the doc set name to be whatever Region is (NW, SW, NE, SE, etc.) and move files from root of the document library to it's respected doc set. I dont mind hard coding the site or web url and doc lib url.
#Setup default variables
$webUrl = Get-SPWeb -Identity "http://CiscoIntranet/sites/VOIP"
$list = $webUrl.GetList("http://CiscoIntranet/sites/VOIP/ForwardTech")
[System.Reflection.Assembly]::LoadWithPartialName(”Microsoft.SharePoint”)
function ProcessMove {
param($folderUrl)
$folder = $web.GetFolder($folderUrl)
foreach ($file in $folder.Files)
{
$docset=$($file.Title);
$destinationFolderUrl = "http://http://CiscoIntranet/sites/VOIP/ForwardTech/" + $docset;
$list.Items.MoveTo($destinationFolderUrl, true);
$webUrl.Update();
}
}