#
# HostsFileCheck.ps1
#

. ".\Common.ps1"

Write-Output "`r`n`r`nHOSTS FILE CHECK ($($hostsFileName)):`r`n"
if ($null -ne $uaHostHashTable -and $null -ne $hostHashTable) {
	foreach ($ip in $uaHostHashTable.Keys) {
		$uaNames = $uaHostHashTable[$ip]
		$uaNamesStr = $uaNames -join " "
		$uaEntryStr = "$($ip) $($uaNamesStr)"
		if (-not $hostHashTable.ContainsKey($ip)) {
			Write-ErrorMsg "Error: missing entry equivalent to '$($uaEntryStr)'"
			continue
		}

		$missingNames = @();
		$names = $hostHashTable[$ip]
		foreach ($uaName in $uaNames) {
			if (-not ($names -contains $uaName)) {
				$missingNames += $uaName
			}
		}
		if (0 -lt $missingNames.count) {
			Write-ErrorMsg "Error: entry or entries for $($ip) missing the following names: $($missingNames -join ' ')"
		} else {
			foreach ($uaName in $uaNames) {
				Write-Output "Success: found $($ip) $($uaName)"
			}
		}
	}
}