For the search, the possibilities in Windows Explorer are limited. You can search for files that are larger than 128 megabytes. That’s nice. But what if to search for files larger than 2 GB?
Run the following command to search your hard drive C: for files larger than 2 GB.
Get-Childitem -Path C:\ -File -Recurse -ErrorAction SilentlyContinue | Where-Object {$_.Length -gt 2GB}
Ups. Now all know that i play Company of Heroes. 😕
And here is the more advanced version:
Get-ChildItem -Path C:\ -File -Recurse -ErrorAction SilentlyContinue | Where-Object {$_.Length -gt 2GB} | Sort-Object length -Descending | Select-Object Name,Directory,@{n='GB';e={"{0:N2}" -F ($_.length/ 1GB)}} | Format-List Name,Directory,GB
Or send it to Out-GridView for a nice view.
Get-ChildItem -Path C:\ -File -Recurse -ErrorAction SilentlyContinue | Where-Object {$_.Length -gt 2GB} | Sort-Object length -Descending | Select-Object Name,Directory,@{n='GB';e={"{0:N2}" -F ($_.length / 1GB)}} | Out-GridView -Title "Large Files"
Categories: PowerShell