List all contents of path in PowerShell

And now for something completely different… This little PowerShell script might be useful when trying to locate the biggest files on your hard drive (I’m always low on disk space).

Get-ChildItem d:\ -recurse | where {$_.Length -ge 0} | sort -Property Length -desc | select Length, Directory, Name, LastAccessTime, Mode | ogv 

It takes all contents of D:\ (Get-ChildItem d:\ -recurse), looks for files of specific size ($_.Length -ge 0), orders them by size descending (sort -Property Length -desc) and outputs interesting information to the Out-GridView. If you want to see it in Excel instead, replace ogv with Export-Csv and then import it to Excel (or use method described here).


Leave a Reply

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

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

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s