Skip to content

Instantly share code, notes, and snippets.

@jaredmo
Created July 30, 2019 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaredmo/90edde98c08bf963309fb6da01652b88 to your computer and use it in GitHub Desktop.
Save jaredmo/90edde98c08bf963309fb6da01652b88 to your computer and use it in GitHub Desktop.
Diff checking files with PowerShell
#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