A high-performance PowerShell module for calculating folder sizes using inline C# code. This module provides lightning-fast folder size calculations that are 3-10x faster than native PowerShell methods, with support from bytes to petabytes.
- ⚡ Ultra-fast performance - 3-10x faster than
Get-ChildItem | Measure-Object - 🔄 Parallel processing - Multi-threaded calculations for even better performance
- 📊 Multiple size units - Automatic conversion to KB, MB, GB, TB, and PB
- 🎯 Smart unit selection -
BestUnitproperty shows the most readable format - 📈 Detailed reporting - File counts, folder counts, and calculation timing
- 🛡️ Error resilient - Gracefully handles access denied and missing files
- 🔗 Pipeline support - Works with PowerShell pipeline for batch operations
- 🏢 Enterprise ready - Handles massive directory structures efficiently
Phellams modules are available from PowerShell Gallery and Chocolatey. you can access the raw assets via Gitlab Generic Assets or nuget repository via Gitlab Packages.
| ▓▓▓▓▒▒▒▒░░░ | ▓▓▓▓▒▒▒▒░░░ | ▓▓▓▓▒▒▒▒░░░ |
|---|---|---|
| 📦 PSGallery | |
|
| 📦 Chocolatey |
| ▓▓▓▓▒▒▒▒░░░ | ▓▓▓▓▒▒▒▒░░░ | ▓▓▓▓▒▒▒▒░░░ |
|---|---|---|
| 💼 Releases/Tags | |
|
Using nuget: See the packages page for installation instructions.
For instructions on adding
nugetsources packages from GitLab see Releases artifacts or via the Packages page.
The latest release artifacts can be downloaded from the Generic Assets Artifacts page.
# Clone the repository
git clone https://gitlab.com/phellams/fastfsc.git
cd fastfsc
import-module .\# Import module from module directory
Import-Module -name Fastfsc
# Basic usage
Get-FolderSizeFast -Path "C:\Windows"
# Detailed information with file/folder counts
Get-FolderSizeFast -Path "C:\Program Files" -Detailed
# Parallel processing for large directories
Get-FolderSizeParallel -Path "D:\LargeDataset"
# Pipeline support
"C:\Users", "C:\Program Files" | Get-FolderSizeFastThe main function for calculating folder sizes with optional detailed reporting.
Parameters:
Path(Mandatory) - The folder path to analyzeDetailed(Switch) - Include file counts, folder counts, and additional metrics
Example Output:
Path : C:\Program Files
SizeBytes : 12884901888
SizeKB : 12583892.5
SizeMB : 12289.93
SizeGB : 12.001
SizeTB : 0.0117
SizePB : 0.00001
BestUnit : 12.0 GB
Detailed Output:
Path : C:\Program Files
SizeBytes : 12884901888
SizeKB : 12583892.5
SizeMB : 12289.93
SizeGB : 12.001
SizeTB : 0.0117
SizePB : 0.00001
BestUnit : 12.0 GB
FileCount : 45234
FolderCount : 3421
High-performance version using parallel processing for maximum speed on large directories.
Parameters:
Path(Mandatory) - The folder path to analyze
Example Output:
Path : D:\BigData
SizeBytes : 5497558138880
SizeKB : 5368708135
SizeMB : 5242885.88
SizeGB : 5120.005
SizeTB : 5.0
SizePB : 0.00488
BestUnit : 5.0 TB
CalculationTimeMs: 2847
Generates a detailed report for a folder, including file counts, folder counts, and additional metrics, uses Get-FolderSizeParallel internally.
Parameters:
Path(Mandatory) - The folder path to analyzeFormat(Optional) - Output format: "json" or "xml"
Example Output:
# Generate a report
Path : G:\devspace\projects\powershell\
SizeBytes : 5325303150
SizeMB : 5078.6
SizeGB : 4.96
FileCount : 18745
FolderCount : 9136
BestUnit : 4.96 GB
CalculationTimeMs : 2277
CalculationTimeSec : 2.28
CalculationTimeMin : 0.04
Path : G:\devspace\projects\web\
SizeBytes : 5505939633
SizeMB : 5250.87
SizeGB : 5.128
FileCount : 92296
FolderCount : 14280
BestUnit : 5.13 GB
CalculationTimeMs : 3873
CalculationTimeSec : 3.87
CalculationTimeMin : 0.06# Analyze a single folder
$result = Get-FolderSizeFast -Path "C:\Users\Documents"
Write-Host "Documents folder is $($result.BestUnit)"# Analyze multiple folders
$folders = @("C:\Program Files", "C:\Program Files (x86)", "C:\Windows")
$results = $folders | Get-FolderSizeFast | Sort-Object SizeBytes -Descending
$results | Format-Table Path, BestUnit, @{Name="Files";Expression={$_.FileCount}} -AutoSize$folders = @("C:\Program Files", "C:\Program Files (x86)", "C:\Windows")
$results = $folders | Get-FolderReport
$results | Format-Table Path, BestUnit, @{Name="Files";Expression={$_.FileCount}} -AutoSize# Compare performance
$stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
$result1 = Get-FolderSizeFast -Path "D:\LargeFolder"
$time1 = $stopwatch.ElapsedMilliseconds
$stopwatch.Restart()
$result2 = Get-FolderSizeParallel -Path "D:\LargeFolder"
$time2 = $stopwatch.ElapsedMilliseconds
Write-Host "Standard: $time1 ms vs Parallel: $time2 ms"# Analyze network storage
$shares = @("\\server\share1", "\\server\share2", "\\server\archive")
$results = $shares | ForEach-Object {
try {
Get-FolderSizeParallel -Path $_
} catch {
Write-Warning "Could not access $_: $($_.Exception.Message)"
}
}
$results | Sort-Object SizeBytes -Descending | Format-Table Path, BestUnit, CalculationTimeMs# Find the largest subdirectories in a path
$parentPath = "C:\Users"
$subfolders = Get-ChildItem -Path $parentPath -Directory | ForEach-Object {
Get-FolderSizeFast -Path $_.FullName
} | Sort-Object SizeBytes -Descending | Select-Object -First 10
$subfolders | Format-Table Path, BestUnit -AutoSize| Method | Time (Example) | Memory Usage | Notes |
|---|---|---|---|
| Native PowerShell | 45 seconds | High | Get-ChildItem -Recurse | Measure-Object Length -Sum |
| Get-FolderSizeFast | 12 seconds | Low | Optimized C# with error handling |
| Get-FolderSizeParallel | 6 seconds | Medium | Multi-threaded for large directories |
Results vary based on directory structure, file count, and system specifications
| Unit | Bytes | Example Usage |
|---|---|---|
| KB | 1,024 | Small files and documents |
| MB | 1,048,576 | Photos, music files |
| GB | 1,073,741,824 | Movies, software installations |
| TB | 1,099,511,627,776 | Large datasets, media libraries |
| PB | 1,125,899,906,842,624 | Enterprise data warehouses |
The BestUnit property automatically selects the most appropriate unit for display.
The module gracefully handles common issues:
- Access Denied: Skips files/folders without permissions and continues
- Network Timeouts: Continues processing other directories
- Missing Paths: Returns clear error messages
- Long Path Names: Handles Windows long path limitations
- Locked Files: Skips files in use by other processes
- Windows PowerShell 5.1 or PowerShell 7+
- .NET Framework 4.5+ (for Add-Type compilation)
- Appropriate file system permissions for target directories
# Run PowerShell as Administrator for system directories
# Or use specific credentials for network shares# Use the parallel version for better network performance
Get-FolderSizeParallel -Path "\\network\path"# The C# implementation is memory efficient, but for extremely large
# directories (millions of files), consider processing subdirectories individuallyThis module is released under the MIT License.
This code is provided as-is for educational and practical use. Feel free to modify and distribute according to your needs.