[Parameter(Mandatory = $true)]
[Parameter(Mandatory = $true)]
[Parameter(Mandatory = $false)]
[switch]$IncludeSubfolders = $false
function Get-DllVersions {
if (-not (Test-Path $FolderPath)) {
Write-Error "Folder path '$FolderPath' does not exist."
$dllFiles = Get-ChildItem -Path $FolderPath -Filter "*.dll" -Recurse:$Recurse
foreach ($dll in $dllFiles) {
$versionInfo = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($dll.FullName)
$relativePath = $dll.FullName.Replace($FolderPath, "").TrimStart('\')
$dllVersions[$relativePath] = @{
FileVersion = $versionInfo.FileVersion
ProductVersion = $versionInfo.ProductVersion
Write-Warning "Could not get version info for: $($dll.FullName) - $($_.Exception.Message)"
$dllVersions[$relativePath] = @{
FileVersion = "Unable to read"
ProductVersion = "Unable to read"
function Compare-DllVersions {
# Get all unique DLL names from both folders
$allDlls = @($Folder1Dlls.Keys) + @($Folder2Dlls.Keys) | Sort-Object -Unique
foreach ($dllName in $allDlls) {
$dll1 = $Folder1Dlls[$dllName]
$dll2 = $Folder2Dlls[$dllName]
# DLL only exists in Folder2
$differences += [PSCustomObject]@{
Status = "Only in $Folder2Name"
Folder1_FileVersion = "N/A"
Folder2_FileVersion = $dll2.FileVersion
elseif ($null -eq $dll2) {
# DLL only exists in Folder1
$differences += [PSCustomObject]@{
Status = "Only in $Folder1Name"
Folder1_FileVersion = $dll1.FileVersion
Folder2_FileVersion = "N/A"
if ($dll1.FileVersion -ne $dll2.FileVersion) {
$differences += [PSCustomObject]@{
Status = "File Version Diff"
Folder1_FileVersion = $dll1.FileVersion
Folder2_FileVersion = $dll2.FileVersion
$Folder1 = $Folder1 | Resolve-Path
$Folder2 = $Folder2 | Resolve-Path
Write-Host "Comparing DLL versions between folders..." -ForegroundColor Green
Write-Host "Folder 1: $Folder1" -ForegroundColor Cyan
Write-Host "Folder 2: $Folder2" -ForegroundColor Cyan
Write-Host "Include Subfolders: $IncludeSubfolders" -ForegroundColor Cyan
# Get DLL versions from both folders
Write-Host "Scanning Folder 1..." -ForegroundColor Yellow
$folder1Dlls = Get-DllVersions -FolderPath $Folder1 -Recurse $IncludeSubfolders
Write-Host "Scanning Folder 2..." -ForegroundColor Yellow
$folder2Dlls = Get-DllVersions -FolderPath $Folder2 -Recurse $IncludeSubfolders
Write-Host "Found $($folder1Dlls.Count) DLLs in Folder 1" -ForegroundColor Magenta
Write-Host "Found $($folder2Dlls.Count) DLLs in Folder 2" -ForegroundColor Magenta
$differences = Compare-DllVersions -Folder1Dlls $folder1Dlls -Folder2Dlls $folder2Dlls -Folder1Name "Folder1" -Folder2Name "Folder2"
if ($differences.Count -eq 0) {
Write-Host "No differences found between the DLL versions in both folders!" -ForegroundColor Green
Write-Host "Found $($differences.Count) differences:" -ForegroundColor Red
# Display the differences in a formatted table
$differences | Format-Table -AutoSize -Wrap
Write-Host "Comparison complete!" -ForegroundColor Green