item full ejemplos content childitem powershell get-childitem

full - Limitación de Powershell Get-ChildItem por el intervalo de fechas de creación de archivos



powershell foreach (3)

Utilizo un comando de Powershell para generar un informe CSV de ciertos tipos de archivos. Mi objetivo es averiguar cuántos se agregaron durante un intervalo de fechas en particular. En este momento, el script encuentra todo y ordeno por fecha para encontrar mi número. Me gustaría modificar el comando para que solo devuelva objetos dentro de un período de creación de fecha, es decir, si este archivo se creó entre el 1 de marzo de 2013 y el 31 de marzo de 2013. Probablemente haya una forma de limitar el comando en un intervalo de fechas, probablemente utilizando Select- Objeto, simplemente no puedo entenderlo.

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


Arreglado...

Get-ChildItem C:/Windows/ -recurse -include @("*.txt*","*.pdf") | Where-Object {$_.CreationTime -gt "01/01/2013" -and $_.CreationTime -lt "12/02/2014"} | Select-Object FullName, CreationTime, @{Name="Mbytes";Expression={$_.Length/1Kb}}, @{Name="Age";Expression={(((Get-Date) - $_.CreationTime).Days)}} | Export-Csv C:/search_TXT-and-PDF_files_01012013-to-12022014_sort.txt


Usa Where-Object , como:

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''


Use Where-Object y pruebe el $_.CreationTime :

Get-ChildItem ''PATH'' -recurse -include @("*.tif*","*.jp2","*.pdf") | Where-Object { $_.CreationTime -ge "03/01/2013" -and $_.CreationTime -le "03/31/2013" }