1

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 1

2


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()
7
  • 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, 2015 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, 2015 at 10:08
  • I edit my answer. You must use $list.folders not $list.items Feb 26, 2015 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, 2015 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, 2015 at 11:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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