

$folderOutput.GetEnumerator() | sort-Object Name | format-table -autosize | out-file -width $outputWidth $findFilesFoldersOutput -append $folderOutput.Add("$targetDir", "$folderSizeComplete") $total = "" -f ($folderSize / 1MB) + "MB" $disk = Get-WmiObject Win32_LogicalDisk -Filter "DeviceID='$diskDrive'" | Select-Object Size,FreeSpace $Time = Get-Date -format "dd-MMM-yyyy-HH-mm" # Search for specific file extensions - Default *.* # Limit number of rows on output, top XX files $findFilesFoldersOutput = "C:\FindLargestFilesAndFolders.txt" # appended to the txt file generated during the initial scan. # the size of all sub folders within a particular folder, output will be

At the end of the script is an option to scan and list # folders sizes of the c:\ drive (default). # This script will find the 10 (default) largest files and then list the

I find this script particularly useful in situations where you have a lot of servers that are being monitored for disk space and you need to quickly and easily find the largest offenders but take all of that information and put it in a readable format. This is a super easy to use and flexible PowerShell script to find out what the largest files and folders are on a single drive. 2021/04/powershell-script-quickly-find-the-largest-files/ Update – – I have an updated version of this script that is a little more flexible and has better output, you can find the new script here:
