A PowerShell module for auditing, organizing, deduplicating, and maintaining large external drives (3 TB+).
| Feature | Description |
|---|---|
| Fast Audit | Recursively scans a drive and exports file metadata to CSV |
| Hash Caching | Stores SHA256 hashes in a JSON cache; only rehashes files that have changed |
| Auto-Categorization | Moves files into Projects / Media / Archives / Uploads / System folders based on extension and keyword patterns |
| Duplicate Resolution | Detects exact duplicates via hash; keeps the newest copy and removes the rest |
| Cleanup | Removes empty directories, reports duplicate groups, compresses the Archives folder |
| Visual Tree Map | Generates a Unicode tree of the drive saved to a .txt file |
| Real-Time Status | Get-DriveStatus returns the currently running operation, start time, and details |
| Scheduled Maintenance | Registers a Windows Scheduled Task to run audits automatically (Daily or Hourly) |
| WPF GUI | Optional graphical launcher for all operations β no command line required |
DriveTools/
βββ 2.0/
β βββ DriveTools.psm1 # Module implementation
β βββ DriveTools.psd1 # Module manifest
βββ tests/
β βββ DriveTools.Tests.ps1 # Pester test suite
βββ tools/
β βββ DriveTools.GUI.ps1 # WPF graphical launcher
β βββ Invoke-DriveBenchmark.ps1 # Performance benchmark script
βββ profile-snippet.ps1 # PowerShell profile snippet
βββ README.md
$dest = "$env:USERPROFILE\Documents\WindowsPowerShell\Modules\DriveTools\2.0"
New-Item -Path $dest -ItemType Directory -Force
Copy-Item DriveTools.psm1, DriveTools.psd1 -Destination $destgit clone https://github.com/you/DriveTools.git
Set-Location DriveTools
.\Install.ps1 # copies module to the user module pathImport-Module DriveTools
Get-Module DriveTools | Select-Object Name, Version, ExportedFunctionsImport-Module DriveTools
# 1. Audit the drive
$csv = Invoke-DriveAuditFast -RootPath M:\ -IncludeHashes
Write-Host "Report saved to $csv"
# 2. Preview categorization without moving anything
Invoke-DriveCategorize -DryRun
# 3. Apply categorization
Invoke-DriveCategorize
# 4. Find and remove duplicates (dry-run first!)
Resolve-DriveDuplicates -DryRun
Resolve-DriveDuplicates
# 5. Clean up empty folders
Invoke-DriveCleanup -RemoveEmptyDirectories -ReportDuplicates
# 6. View a tree map of the drive
Show-DriveVisualMap -MaxDepth 3
# 7. Schedule nightly maintenance
Register-DriveMaintenanceTask -Schedule Daily
# 8. Monitor long-running operations
Get-DriveStatusScans a drive and exports a CSV with file metadata.
-RootPath <string> Drive or folder to scan (default: M:\)
-OutputCsvPath <string> Destination CSV path
-IncludeHashes <switch> Compute SHA256 for every file
Builds or refreshes a JSON hash cache; unchanged files reuse their stored hash.
-RootPath <string> Drive root
-CachePath <string> Path to HashCache.json
Moves files into category folders based on extension and keyword matching.
-RootPath <string> Drive root
-CategoryMap <hashtable> Custom map (category β pattern list)
-DisableDefaultCategoryMap <switch> Skip the built-in category map
-DryRun <switch> Log actions without moving files
Default CategoryMap:
| Category | Triggers |
|---|---|
| Projects | Unity, Project, Source, .sln, .csproj, Perseus |
| Media | .wav, .mp3, .flac, .mp4, .mov, .mkv, .jpg, .png, .psd, .ai β¦ |
| Archives | backup, export, .zip, .rar, .7z, .bak β¦ |
| Uploads | UPLOADS, upload, .torrent, .nfo |
| System | installer, setup, .msi, .exe, .dll, .log |
Hashes all files, groups identical hashes, keeps the newest copy.
-RootPath <string> Drive root
-DryRun <switch> Log what would be deleted without deleting
Composite cleanup: empty directories, duplicate reports, archive compression.
-RemoveEmptyDirectories <switch> Delete zero-item folders
-ReportDuplicates <switch> Log duplicate groups to the log file
-CompressArchives <switch> Zip the Archives\ subfolder
Renders a Unicode tree of the directory structure.
-RootPath <string> Root to map
-MaxDepth <int> Recursion limit (default: 3)
-OutputPath <string> Where to save the .txt file
Registers a Windows Scheduled Task that calls Invoke-DriveAuditFast automatically.
-TaskName <string> Task name (default: DriveMaintenance)
-Schedule <string> Daily | Hourly
Returns the currently active operation, start time, and last-update timestamp.
All operations write to daily log files:
%USERPROFILE%\Documents\DriveLogs\Drive_YYYY-MM-DD.log
Hash cache is stored at:
%USERPROFILE%\Documents\DriveLogs\Drive_HashCache.json
Requires Pester 5.
Install-Module Pester -Force -SkipPublisherCheck
Invoke-Pester .\tests\DriveTools.Tests.ps1 -Output DetailedLaunch the graphical interface with:
.\tools\DriveTools.GUI.ps1The GUI provides one-click access to all operations, a live status display, and a log viewer.
You can override the default drive root and log path in your profile or before importing the module by editing the module variables after import:
Import-Module DriveTools
# Point to a different drive
(Get-Module DriveTools).Invoke({ $Script:Drive_DefaultRoot = 'E:\' })Or supply -RootPath on every call.
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Add Pester tests for any new functions
- Open a pull request
MIT β see LICENSE.