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. This command searches for files inside c:\mydata folder. You can run this against any folder.
Get-ChildItem -path c:\mydata -recurse | Where-Object { ($_.Length /1GB) -gt 2 } | ForEach-Object { ($_.length/1GB).Tostring("0.00") }
Happy Learning,
Sitaram Pamarthi
Comments on this entry are closed.
A small correction needed in the command above. The switch should be “-recurse” instead of “-recursive”. Thanks.
Thanks for pointing the typo. I made the correction.
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.
Thanks for sharing it.
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.
What if we have to do it on 10 servers remotely can it take a server.txt as input and write for all the OS.
Hi, You can execute this code through PowerShell Remoting.
Is there also a way to make this export to a /txt or .csv file as well as display it on screen?
It worked ! thanks a lot for sharing
Thank you for the feedback.