I have a document library, I have used a powershell command to change the created date of the files uploaded in that library. However, I also want to change the created date of a Folder which is uploaded in that library. Please suggest a powershell command.
1 Answer
Try this PS snippet:
$foldersColl = $oList.GetItems($folderquery)
foreach($folder in $foldersColl)
{
$folder["Created"] = $dateToSet
$folder.Update()
}
Updated answer (after reading comments)
Add-PSSnapin Microsoft.SharePoint.PowerShell
$web = get-SPWeb "http://portal/";
$list =$web.lists["Documents"];
$folderName = "BNFSDocs";
$item = $list.folders | ? {$_.Name -eq $folderName}
$dateToStore = Get-Date "10/02/1984"
$item["Created"] = $dateToStore
$item.UpdateOverwriteVersion()
-
1Thanks ALexander. But pls help me. This is my PS code. $url = "synpunspd0366:44175/sites/SAMS/KR" $listName = "Domain" $folderName = "BNFSDocs" #Get the appropriate list from the web $web = get-SPWeb $url $list = $web.lists[$listName] #Get the file using the filename $item = $list.Items | ? {$_.Name -eq $folderName} $dateToStore = Get-Date "10/02/1984" $item["Created"] = $dateToStore $item.UpdateOverwriteVersion() But it is giving error,where to put your snippet?pls help Feb 26, 2015 at 9:55
-
1Alexander I dont want to use foreach, I just have one folder in my library as BNFSDOcs want to change its created date Feb 26, 2015 at 10:08
-
I edit my answer. You must use $list.folders not $list.items Feb 26, 2015 at 10:26
-
1Thanks. How can I pass parameters to powershell command? I need to pass folder name and created date. Feb 26, 2015 at 10:36
-
1I did that. But I am facing a small problem. If I have to change a file's created date which is inside a folder then? It is not working. Please help Feb 26, 2015 at 11:59