b1nary0mega
7/5/2017 - 7:35 PM

compare 2 directories in powershell and omitt the directories "archive" and "mail"

compare 2 directories in powershell and omitt the directories "archive" and "mail"

REM Do a directory comparison, but ommit directories archive and mail
$fso_A = Get-ChildItem -Recurse -Path 'd:\Folder_To\Copy' | ? { $_.PsIsContainer -and $_.FullName -notmatch 'archive' -and $_.FullName -notmatch 'mail' }
$fso_B = Get-ChildItem -Recurse -Path 'e:\Folder_To\Copy' | ? { $_.PsIsContainer -and $_.FullName -notmatch 'archive' -and $_.FullName -notmatch 'mail' }

REM do a comparison and output directory location
Compare-Object -ReferenceObject $fso_A -DifferenceObject $fso_B -PassThru | % {$_.FullName} >> Directory_Comparison-Full_Path-Omitt_Arhive-Mail.txt