≡ Menu

List the files greater than given size using powershell

Below powershell code helps you to list the files which are greater than given size(2GB in this case) and output the file sizes in MB/GB format.

PS C:local> Get-ChildItem -path c:mydata -recurse | where  { ($_.Length /1GB) -gt 2 } | foreach { ($_.length/1GB).Tostring(“0.00”) }
Do write in comments section here if you need any charification.
Happy Learning,
Sitaram Pamarthi

{ 6 comments… add one }
  • Muhammad Usman Janjua May 22, 2011, 11:15 am

    A small correction needed in the command above. The switch should be “-recurse” instead of “-recursive”. Thanks.

  • Sitaram Pamarthi May 23, 2011, 4:45 pm

    Thanks for pointing the typo. I made the correction.

  • Martin February 17, 2016, 12:48 pm

    Better solution: fileas larger than 50 MB on drive C:
    Get-ChildItem -Path C:\ -Recurse | Where-Object {$_.length/1MB -gt 50} | select fullname,@{n=”Size MB”;e={$_.length/1MB}}
    Output of this command is still object, so you cane pipe it for instance to remove-item and so on.

  • Abigail Ava January 21, 2017, 2:38 pm

    Sometimes we get an error when we try to delete a File or a folder for no reason , but of course there is a reason.We have many damage file or blocked files.Do not worry if we want to remove the error files or too long path files from our system,here I suggest a smooth way.So use “Long path tool” software and keep yourself.

Leave a Comment