ファイルの最終アクセス日を確認してみる

アーカイブシステムの動作確認中に調べてみた方法となります。

アーカイブポリシーとして、『最終アクセス日から××日』という条件になっており、あるファイル/フォルダがそのポリシーに合致するかどうかどうか確認したいとき、エクスプローラーでプロパティを見てしまうと、その操作を行った日時に更新されてしまいます。ので、PowerShellから

Get-ChildItem . | Select-Object Name, Length, CreationTime, LastAccessTime

で調べてみてください。

これの応用系で、30日以上前のファイル一覧が欲しい時は、

Get-ChildItem . -Recurse | Where-Object {$_.LastAccessTime -lt (Get-Date).AddDays(-30)} | Select-Object FullName, LastAccessTime | Out-String -Width 4096

とやってみたりします。

尚、ここで使えるプロパティ一覧は、

Get-ChildItem | Get-Member -MemberType property

で確認ください。

This website stores cookies on your computer. These cookies are used to provide a more personalized experience and to track your whereabouts around our website in compliance with the European General Data Protection Regulation. If you decide to to opt-out of any future tracking, a cookie will be setup in your browser to remember this choice for one year.

Accept or Deny