We help IT Professionals succeed at work.

size of file

163 Views
Last Modified: 2017-04-03
Hi All,

I have the code below to find files that are older than 6 moths and greater than 1 gb:

$pathname = Read-Host "Please Enter Path Name: "
$files = Get-ChildItem $pathname -Recurse -File | 
    Where-Object { $_.LastAccessTime -le (Get-date).AddMonths(-6) -and $_.Length -ge 1GB } | 
  Select FullName,CreationTime,LastAccessTime,LastWriteTime |
Export-Csv "c:\$(($pathname -split "\\")[-1]).csv" -NTI 

Open in new window


I need to add to the spreadsheet the size of the files, how do I do this?
Comment
Watch Question

PowerShell Developer
CERTIFIED EXPERT
Top Expert 2010
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION