TestDrive and file creation dates

I have a function that selects certain files based on when they were created, but I’m struggling with a way to create and test this function with TestDrive because of the date criteria. Does anybody have any suggestions on ways to test this function using TestDrive?

Since TestDrives are temporary, it wont be possible to use it to test based on dates. IMO, you will have to prepare a dedicated test bed for this.

Maybe a bit late on the ball here, but the CreationDate property is read/write, so you can assign a creation date when you create the file(s)

$file = New-Item -Path . -Name ‘test file.txt’ -ItemType ‘file’
$file.CreationDate = Get-Date ‘2020-01-01’

(Also applies to LastWriteTime etc.)

@jbrusoe That is an option you can try if it works.