Limiting Powershell Get-ChildItem by File Creation Date Range

前端 未结 3 1814
Happy的楠姐
Happy的楠姐 2020-12-14 15:23

I use a Powershell command to generate a CSV report of certain file types. My goal is to find out how many were added during a particular date range. Right now, the script f

3条回答
  •  没有蜡笔的小新
    2020-12-14 16:00

    Use Where-Object, like:

    Get-ChildItem 'PATH' -recurse -include @("*.tif*","*.jp2","*.pdf") | 
    Where-Object { $_.CreationTime -gt "03/01/2013" -and $_.CreationTime -lt "03/31/2013" }
    Select-Object FullName, CreationTime, @{Name="Mbytes";Expression={$_.Length/1Kb}}, @{Name="Age";Expression={(((Get-Date) - $_.CreationTime).Days)}} | 
    Export-Csv 'PATH\scans.csv'
    

提交回复
热议问题