# Report-FileStats.ps1 # # report Filestatistics like Name, Path, size, age lastmodified # # Performance Win7 local SSD 115403 Files in 45 Sec = 16 MB CSV-File param ( [string]$basepath = "c:\share" ) write-host "Report-FileStats: Start" write-host "Report-FileStats: Parameter basepath :" $basepath $now = (get-date) write-host "Report-FileStats: Current DateTime :" $reportcsv [uint32]$count=0 get-childitem -path $basepath -recurse | % { #write-host " File:" $_.fullname " - " $_.$dateproperty -nonewline if (!$_.PSIsContainer) { $count++ if ($count%1000 -eq 0) { write-host "Files:" $count } $result = $_ | select Name,Extension,Directory,Length,Sizegroup,LastWriteTimeUtc,Age,AgeGroup if ($_.Length -lt 1) { $result.Sizegroup = 0 } else { $result.Sizegroup = [int]([math]::log10($_.Length)+0.5) } $result.Age = ($now - ($_.lastwritetimeutc)).days if ($result.Age -lt 7) { $result.AgeGroup = "0" } elseif ($result.Age -lt 30) { $result.AgeGroup = "1" } elseif ($result.Age -lt 365) { $result.AgeGroup = "2" } else { $result.AgeGroup = "3" } $result } else { #write-host "Dir:" $_.fullname } } write-host "Total Files: $count" write-host "Report-FileStats: End"