
PowerShellで
・ファイルの更新日時を変更
できます!
コード
ここでは例として
・デスクトップ配下のファイル「aiueo.txt」の
・更新日時を変更
します。
※「2022年12月1日 0:00:00」から「2022年12月5日 12:00:00」へ変更します。

# 対象ファイル
$targetFile = "C:\Users\user\Desktop\aiueo.txt"
# 変更後の日時
$lastWriteTime = "2022/12/05 12:00:00"
$ws = New-Object -ComObject Wscript.Shell
# 対象ファイルの存在有無を確認
if (-Not(Test-Path $targetFile)) {
$ws.popup("対象ファイルが存在しないため、処理を終了します。")
exit
}
# 更新日時を変更
Set-ItemProperty $targetFile -name LastWriteTime -value $lastWriteTime
$ws.popup("更新日時を変更しました。")
実行結果
ファイルの更新日時を変更できました。
※「2022年12月1日 0:00:00」から「2022年12月5日 12:00:00」へ変更できました。


参考①
ファイルの更新日時を取得することもできます。
詳細は以下の記事をご確認ください。
参考②
上記で使用した以下の詳細は、公式サイトをご確認ください。
●「Set-ItemProperty」コマンドレット