IT Nota

  • Home
  • How To
  • .NET
  • WordPress
  • Contact

How to Change the Time Stamp of a File Using PowerShell

From time to time, you may need to modify the time stamp of a file for archiving or any other reasons.

This PowerShell script comes in handy when you need to do it. This is for a one-off tweak of a file. If you’re doing this in bulk, it’s probably better to use Robocopy with a /copy:T option (see an example here) to copy all the attributes including the time stamp.

PowerShell script to change the timestamp for a file

(Get-Item "C:\Temp\ITNota.txt").LastWriteTime=("6/1/2022 15:00:00")

Or

(Get-Item "C:\Temp\ITNota.txt").LastWriteTime=("1 June 2022 15:00:00")

Two versions of the script were provided to eliminate ambiguity of the date system. You just need to use one of them.

If you use the US date format, the first one will work. Otherwise, it’s always safer to spell out the date and the month.

Further Reading

How to Change File Date or Timestamp in Windows

July 20, 2022 Filed Under: How To Tagged With: PowerShell, Windows, Windows Server

Buy me a coffee?

Buy me a coffee If you find any of the articles or demos helpful, please consider supporting my work here, you'll have my big thanks!

Buy me a coffee Support this site
Buy Me a Coffee?

Categories

  • .NET
  • Coding
  • Cybersecurity
  • Database
  • How To
  • Internet
  • Multimedia
  • Photography
  • Programming
  • Resources
  • Review
  • Tips and Tricks
  • Uncategorized
  • Use Case
  • WordPress
  • Writing

Recent Posts

  • How to View Stored Procedure Code in SQL Server
  • How to Find a String in SQL Server Stored Procedures
  • How to Remove Cached Credentials without Rebooting Windows
  • ESP Work Automation: Empowering Enterprises with Streamlined Workflows and Operational Efficiency
  • How to Search for a String in All Tables in a Database

Recent Posts

  • How to View Stored Procedure Code in SQL Server
  • How to Find a String in SQL Server Stored Procedures
  • How to Remove Cached Credentials without Rebooting Windows
  • ESP Work Automation: Empowering Enterprises with Streamlined Workflows and Operational Efficiency
  • How to Search for a String in All Tables in a Database

Tags

.NET .NET Core AdSense ASP.NET Cdonts Dll Classic ASP Code Editor ETL FSharp Genesis Framework Git Google HP Asset Manager HTML5 Hugo IIS Information Security Internet Internet Information Services iOS JAMStack Linux macOS Microsoft Microsoft SQL Server MVC PHP PowerShell Python Simple Mail Transfer Protocol Smtp Server SQL SQL Server SSIS SSMS SSRS Sublime Text Visual Studio Visual Studio Code VPN Windows Windows 8 Windows 10 Windows 2012 Windows Server

Copyright © 2011-2025 IT Nota. All rights reserved. Terms of Use | Privacy Policy | Disclosure