Skip to content

Instantly share code, notes, and snippets.

@celophi
Created July 17, 2017 18:38
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 celophi/3ae0fbf26acd4ed8eab236b1c20661b1 to your computer and use it in GitHub Desktop.
Save celophi/3ae0fbf26acd4ed8eab236b1c20661b1 to your computer and use it in GitHub Desktop.
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