Finding 10 Largest Files

Share |

Join PowerShell.com!
Subscribe to Feed

PowerShell eBook
Sign up for
Your PowerTip of the Day:

Award-winning PowerShellPlus


Admin Guide to PowerShell Remoting


Mastering PowerShell eBook

You may need to find the largest files for possible clean-up when free space on a drive runs low. One way is to have PowerShell examine all file sizes, sort by file size descending, and then pick the 10 largest ones (the 10 first results):

Dir $home -recurse -ea SilentlyContinue |
Sort-Object Length -Descending |
Select-Object -first 10 |
Select-Object FullName, Length, LastWriteTime

You should note that this may take some time to complete. Also, you will see the ErrorAction setting, which hides error messages that may occur when the command hits sub-folders or files you have no access.

Twitter This Tip! ReTweet this Tip!


Posted Apr 27 2010, 08:00 AM by ps1

Comments

uberVU - social comments wrote Social comments and analytics for this post
on 04-27-2010 10:54 AM

This post was mentioned on Twitter by PowerTip: Finding 10 Largest Files in #PowerShell http://bit.ly/bEVsKA

Twitter Trackbacks for Finding 10 Largest Files - Power Tips - PowerShell.com [powershell.com] on Topsy.com wrote Twitter Trackbacks for Finding 10 Largest Files - Power Tips - PowerShell.com [powershell.com] on Topsy.com
on 04-27-2010 10:58 AM

Pingback from  Twitter Trackbacks for                 Finding 10 Largest Files - Power Tips - PowerShell.com         [powershell.com]        on Topsy.com

Copyright 2012 PowerShell.com. All rights reserved.