How to set LastWriteTime property of a file?

Question:

I would like to change the creation date of the files that I generate with this script :

So it gives me theses files :

I want to modify the LastWriteTime property of each files, I want it to be the same as the date in the file name.

Example for this file "client 2013-08-15 01-00-00.bak" the LastWriteTime will be "15/08/2013 01:00"

I’m stuck and I do not how can we do that

Thank you

Answer:

Not tested, but try this in your loop after you call New-Item:

If you want to see a full listing of things you can do with FileInfo objects, try calling $file | gm in your powershell console. You could also view the docs on MSDN.

Source:

How to set LastWriteTime property of a file? by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply