LoginSignup
4
1

[PowerShell] ファイルの更新日時/作成日時を取得/変更する

Last updated at Posted at 2023-07-13

結論

PowerShellからファイルの更新日時・作成日時を取得・変更できる。
ファイルのパーミッションによっては管理者権限での実行が必要なので注意。

取得

(Get-ItemProperty target.txt).CreationTime # -> 2023年1月1日 12:00:00
(Get-ItemProperty target.txt).LastWriteTime # -> 2023年1月1日 12:00:00

変更

Set-ItemProperty target.txt -name CreationTime -value '2023/01/01 12:00:00' # 作成日時
Set-ItemProperty target.txt -name LastWriteTime -value  '2023/01/01 12:00:00' # 更新日時

参考文献

4
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1