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.


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()
  • 1
    Thanks 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 – user39250 Feb 26 '15 at 9:55
  • 1
    Alexander I dont want to use foreach, I just have one folder in my library as BNFSDOcs want to change its created date – user39250 Feb 26 '15 at 10:08
  • I edit my answer. You must use $list.folders not $list.items – Alexander Ulmaskulov Feb 26 '15 at 10:26
  • 1
    Thanks. How can I pass parameters to powershell command? I need to pass folder name and created date. – user39250 Feb 26 '15 at 10:36
  • 1
    I 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 – user39250 Feb 26 '15 at 11:59

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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