Copy-item cmdlet copies folder with latest timestamp

Welcome Forums General PowerShell Q&A Copy-item cmdlet copies folder with latest timestamp

Viewing 2 reply threads
  • Author
    • #275868
      Topics: 1
      Replies: 0
      Points: 11
      Rank: Member

      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


    • #275961
      Topics: 5
      Replies: 253
      Points: 1,007
      Helping Hand
      Rank: Community Hero

      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.

      This brings up another point which is you shouldn’t really rely on these timestamps because they are very easily modified.

    • #276063
      Topics: 10
      Replies: 203
      Points: 996
      Helping Hand
      Rank: Major Contributor

      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.

Viewing 2 reply threads
  • You must be logged in to reply to this topic.