PowerShell 実践 指定日時前のファイルを表示

PowerShellで指定ディレクトリ配下を参照し、現在日よりもXXXX前につくられたファイルを表示するサンプルです。

#検索するディレクトリ
$a = Get-ChildItem C:\tmp  

#XXXX前
$val = 1

foreach($x in $a){  
    $y = ((Get-Date) - $x.CreationTime).Days  
    if ($y -gt 3 -and $x.PsISContainer -ne $True) {
        write-Host $y
    }
} 

 
powershell記事一覧


Bookmark this on Yahoo Bookmark
Bookmark this on Google Bookmarks
Share on LinkedIn
LINEで送る
Pocket