Quick Contact

How to find files by size with PowerShell

##Mention the path to search the files

$path = "D:\HostingSpaces"

##Find out the files greater than equal to below mentioned size

$size = 100MB

##script to find out the files based on the above input

$largeSizefiles = get-ChildItem -path $path -recurse -ErrorAction "SilentlyContinue" | ? { $_.GetType().Name -eq "FileInfo" } | where-Object {$_.Length -gt $size} | sort-Object -property length -Descending | Select-Object Name, @{Name="SizeInMB";Expression={$_.Length / 1MB}},@{Name="Path";Expression={$_.directory}}

$largeSizefiles | Export-Csv d:\lsfreport.csv 

Additional Articles
X

Partners

© 2013 XGlobe Online Ltd.