PowerShell

PowerShell: How to find large files using Get-Childitem

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}

3.PNG

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

Unbenannt.JPG

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"

Unbenannt1.JPG

Categories: PowerShell

Tagged as: ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.