If you’re looking to manage the storage on your Windows devices, it can be helpful to know which files are taking up the most space on your hard drive. The good news is that you can use a PowerShell script (.ps1) to quickly find the largest files on your C drive.
It can be especially helpful for users who are running out of storage space and need to identify which files are taking up the most space. Give it a try and see how it can help you manage your storage more effectively.
Atera does not guarantee the integrity, availability, security, virus-free, safety, lawfulness, non-infringement, rights’ status, or functionality of the scripts. The use of the shared scripts is at your own risk. Scripts are provided “AS IS”. *
get-ChildItem C:\ -recurse -erroraction silentlycontinue | sort length -descending | select -first 10
How can I list the biggest files on other drives?
You can list files from other drives by replacing the path in the command. If you want to list the top 10 biggest files in the E drive, the script will be:
get-ChildItem E:\ -recurse -erroraction silentlycontinue | sort length -descending | select -first 10
Can I change the number of files listed?
Of course. If you want to list the top 20 biggest files in the C drive, the script will be:
get-ChildItem D:\ -recurse -erroraction silentlycontinue | sort length -descending | select -first 20
- This script will run on Windows 10, 11, Server 2008 and upwards.
- Admin permissions needed to run this script.
- Get-ChildItem cmdlet: Retrieve all the items in the specified location. The recurse parameter is included to ensure that all files and folders within subfolders are also included in the search.
- Sort cmdlet: Sorts the items by length in descending order.
- Select cmdlet: Selects the first 10 items in the sorted list (which will give you the top 10 largest files on your C drive).