Create files with old Creantiontime Timestamp

$i = 1
$totalNumberOfFiles = 10
$daysOld = 180
$fileName = "testfile"

while ($i -lt ($totalNumberOfFiles+1) ) {

$file = $fileName + "_" + $i + ".txt"
New-Item -Name $file -ItemType File
(Get-Item $file).creationtime=$((Get-Date).adddays(-$daysOld))
$i++
}

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.