Created
July 30, 2019 14:58
-
-
Save jaredmo/90edde98c08bf963309fb6da01652b88 to your computer and use it in GitHub Desktop.
Diff checking files with PowerShell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Create catalog | |
New-FileCatalog -Path C:\Users\[user]\Downloads\a -CatalogFilePath C:\Users\[user]\Downloads\SourceCatalog.cat -CatalogVersion 2.0 | |
# Simple diff test | |
Test-FileCatalog -Detailed -Path C:\Users\[user]\Downloads\b -CatalogFilePath C:\Users\[user]\Downloads\SourceCatalog.cat | |
# Detailed diff tests | |
$params = @{ | |
Path = 'C:\Users\[user]\Downloads\b' | |
CatalogFilePath = 'C:\Users\[user]\Downloads\SourceCatalog.cat' | |
Detailed = $true | |
} | |
$result = Test-FileCatalog @params | |
#List added files | |
Write-Output "List added files" | |
$result.PathItems.Keys | Where-Object { -not | |
$result.CatalogItems.ContainsKey($_) } | |
#List removed files | |
Write-Output "" | |
Write-Output "List removed files" | |
$result.CatalogItems.Keys | Where-Object { -not | |
$result.PathItems.ContainsKey($_) } | |
#List changed files | |
Write-Output "" | |
Write-Output "List changed files" | |
$result.PathItems.Keys | Where-Object { $result.CatalogItems[$_] -ne | |
$result.PathItems[$_]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment