Find the Largest Files on your Computer
I have a decent sized SSD and found it running low on free space. I thought, “what is taking so much space?” After an unsuccessful internet search, I decided to write my own script to help me find those large files.
I decided to add parameters to make a given search more customizable. For example, the defaults are 10 largest files on your local machine and local hard-drives. However, you can specify more files (e.g.: 100) or you can search USB drives or remote computers, and save output to CSV files.
Here is the full list of parameters and a few examples. The parameters are positional in the following order. If you choose not to specify any parameters, there are defaults.
-Top = default is 10, this is number of largest files to find in search
-ComputerName = default is localhost, but you can specify to remote computer
-DriveType = default is 3, but you can override with numeric value below
- Unknown (0)
- No Root Directory (1)
- Removable Disk (2)
- Local Disk (3)
- Network Drive (4)
- Compact Disc (5)
- RAM Disk (6)
-CSV = default is false, which will display output, but you can set to true for csv output
Search defaults (10 files, local drives, local computer, display output)
Search USB drive for 10 largest files, display output
C:\Find-LargeFiles.ps1 -DriveType 2
Search for 20 largest files on remote computer
C:\Find-LargeFiles.ps1 -Top 20 -ComputerName remote-machine-name
Search for 100 largest files and output to csv
C:\Find-LargeFiles.ps1 -Top 100 -CSV true
Search USB for 15 largest files and output to csv (see screenshot)
Please download script here: Find-LargeFiles_v1.1
(Note: Windows PowerShell needs to be configured to run scripts. To do this, run the following command in an elevated Windows PowerShell session (open PowerShell by selecting Run as administrator). Type the following to allow the script to run in your current PowerShell session only.)
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass –Force
For more information on execution policy, see Set-ExecutionPolicy.