Tuesday, April 14, 2015

Move Folder from one Document Library to another via PowerShell

$site_urL = "https://sp.group/sites/08544/"
$dest_doclib = "https://sp.group/sites/08544/Products%20old/"
$src_doc_name = "IT Documentation"
$folder_to_move = "Products";

$site = Get-SPSite $site_url
$web = $site.RootWeb
$src_doc = $web.lists[$src_doc_name]
$subfolders = $src_doc.RootFolder.SubFolders["$folder_to_move"]

foreach ($fl in $subfolders.SubFolders)
{    
    #$dest_doc + $fl.Name
    $fl.MoveTo($dest_doclib + $fl.Name)
} 

No comments:

Post a Comment