Audit file migration completeness by comparing file and folder counts between source and destination network shares.
This PowerShell script compares file and folder counts between two network share locations to verify migration completeness. It scans each top-level subfolder and generates an HTML report showing which folders match and which have discrepancies.
This script only reads information. It does NOT copy, move, or modify any files.
Download: compare-migration.ps1
Or download directly via PowerShell:
iwr https://technologist.services/tools/compare_migration/compare-migration.ps1 -OutFile compare-migration.ps1
Save compare-migration.ps1 to a folder on your computer (e.g., C:\Scripts)
Open PowerShell as Administrator and navigate to the script location:
cd C:\Scripts
Execute the script with your source and destination servers/shares:
.\compare-migration.ps1 -Source "oldserver" -SourceShare "users" -Destination "newserver" -DestShare "users"
The script automatically opens the HTML report in your default browser. The report is saved as:
migrationreport-{sharename}-{date}.html
Example: migrationreport-users-feb18_2026.html
If PowerShell blocks the script, you can bypass the execution policy temporarily:
PowerShell.exe -ExecutionPolicy Bypass -File .\compare-migration.ps1 -Source "oldserver" -SourceShare "users" -Destination "newserver" -DestShare "users"
The hostname or IP address of the source server.
Example: -Source "fileserver01"
The name of the share on the source server.
Example: -SourceShare "users"
The hostname or IP address of the destination server.
Example: -Destination "fileserver02"
The name of the share on the destination server.
Example: -DestShare "users"
Custom path for the HTML report. If not specified, defaults to script directory with auto-generated filename.
Example: -ReportPath "C:\Reports\migration-audit.html"
.\compare-migration.ps1 `
-Source "oldnas" `
-SourceShare "departments" `
-Destination "newnas" `
-DestShare "departments" `
-ReportPath "C:\Reports\dept-migration.html"
The script automatically excludes temporary files starting with ~ (like Office temp files) from all comparisons.
~$document.docx are ignoredWhen fewer than 10 files are missing from a folder, the report lists the specific file paths.
Report filenames automatically include the destination share name and date for easy organization.
migrationreport-{sharename}-{mmmdd_yyyy}.htmlmigrationreport-users-feb18_2026.htmlAutomatically excludes NTFS junction points from scans to avoid infinite loops and duplicate counting.
The raw file counts shown may include temp files, but the MATCH/MISMATCH status is determined after excluding temp files. A folder may show different counts but still be marked as MATCH if the only differences are temporary files.
Test connectivity:
Test-Path "\\servername\sharename"
Check your credentials have read access to both shares.
This usually means robocopy couldn't access the folders. Check:
The script now excludes temp files (~*) automatically. If you still see mismatches:
Large folders with many files will take time to scan. The script shows progress:
[1/57] Scanning: username
Consider running during off-hours for large migrations.