-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCompare-Directories.ps1
40 lines (29 loc) · 1.03 KB
/
Compare-Directories.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<#
.SYNOPSIS
Quickly check for differences in files by the MD5 hash.
.DESCRIPTION
Quickly check for differences in files by the MD5 hash.
.PARAMETER Sourcedirectory
This should be the source directory to compare fromt.
.PARAMETER Comparisondirectory
This should be the local directory to compare against.
.EXAMPLE
compare-directories -sourcedirectory "\\server\share\folder" -comparisondirectory "C:\folder\"
.NOTES
@Author Daryl Bizsley 2015
Last Edit 27/3/2015
#>
function Compare-Directories{
[CmdletBinding()]
param(
[string]$sourcedirectory,
[string]$comparisondirectory
)
#Get Hashes of source
$sourcehashes = get-childitem $sourcedirectory |% {@{$_.Name = (Get-FileHash $_.FullName).hash}}
#Get Hashes of others
$comparisonhashes = get-childitem $comparisondirectory |% {@{$_.Name = (Get-FileHash $_.FullName).hash}}
#compare and show non-matching files as output
$results = Compare-Object $sourcehashes $comparisonhashes
$results.InputObject
}