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