Hi All,
I’m new to this forum & powershell, Question may sound silly
I’m writing script to copy folder to remote servers, I tried with copy-item cmdlet and I see folder are copied but with latest timestamp
i do not want the timestamp to be changed
Thank you
There are 3 timestamps with files: Created, Modified and Accessed. Windows updates Created and Accessed when you copy a file this is not really a PowerShell issue but PowerShell can “fix” it.
(Get-Item ".\yourfile.txt").CreationTime = $oldcreationdate
(Get-Item ".\yourfile.txt").lastaccesstime = $oldaccessdate
This brings up another point which is you shouldn’t really rely on these timestamps because they are very easily modified.
tonyd
December 2, 2020, 12:16pm
3
Or you can use robocopy with /DCOPY:T
An example:
robocopy \server\share\path \server\share\path . /E /R:1 /W:1 /XJ /COPY:DAT /DCOPY:T /NP /LOG:C:\temp\robo.log /TEE
There are many switches to robocopy … these are in my opinion the basics.