Skip to content

Instantly share code, notes, and snippets.

@celophi

celophi/differ

Created Jul 17, 2017
Embed
What would you like to do?
param (
[Parameter(Mandatory=$true)]
[String]
$HostList,
[Parameter(Mandatory=$true)]
[String]
$FilePath,
[Parameter(Mandatory=$false)]
[System.Management.Automation.PSCredential]
$Credential
)
$ErrorActionPreference = "Stop"
if (!$Credential) {
$Credential = Get-Credential
}
if (![System.IO.File]::Exists("$PSScriptRoot\$HostList")) {
throw "Error. The file '$HostList' does not exist."
}
$results = @{
"None" = @()
}
$contents = Get-Content "$PSScriptRoot\$HostList"
foreach ($line in $contents) {
try {
Write-Host ("{0}/{1}: Processing: {2}" -f $contents.IndexOf($line), $contents.Count, $line)
$hash = Get-FileHash -Path ("\\{0}\{1}" -f $line, $FilePath)
$results[$hash.Hash] += @($line)
} catch {
$results["None"] += $line
Write-Error $_
}
}
$results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment