Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| temp [2026/02/27 18:15] – created jdlewis | temp [2026/03/09 18:51] (current) – jdlewis | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | <file - temp.txt> | + | . |
| - | # ─── Config ─────────────────────────────────────────────────────────────────── | + | |
| - | $ScriptDir | + | |
| - | $HostsFile | + | |
| - | $SitesFile | + | |
| - | $OutputFile = " | + | |
| - | + | ||
| - | # ─── Colour palette ─────────────────────────────────────────────────────────── | + | |
| - | $Palette = @("# | + | |
| - | + | ||
| - | # ─── Load sites.csv ─────────────────────────────────────────────────────────── | + | |
| - | $SiteRows | + | |
| - | $SiteMap | + | |
| - | $SiteColors = @{} # site name -> colour | + | |
| - | $SiteOrder | + | |
| - | $ColorIdx | + | |
| - | + | ||
| - | foreach ($row in $SiteRows) { | + | |
| - | $prefix = $row.prefix.Trim() | + | |
| - | $site = $row.site.Trim() | + | |
| - | $SiteMap[$prefix] = $site | + | |
| - | if (-not $SiteColors.ContainsKey($site)) { | + | |
| - | $SiteColors[$site] = $Palette[$ColorIdx % $Palette.Count] | + | |
| - | $SiteOrder.Add($site) | + | |
| - | $ColorIdx++ | + | |
| - | } | + | |
| - | } | + | |
| - | + | ||
| - | # ─── DNS lookup + site matching ─────────────────────────────────────────────── | + | |
| - | $HostRows | + | |
| - | $Results | + | |
| - | $SiteCounts = @{} | + | |
| - | $ErrorCount = 0 | + | |
| - | $Total | + | |
| - | + | ||
| - | foreach ($h in $HostRows) { | + | |
| - | $hostname = $h.hostname.Trim() | + | |
| - | $name = $h.name.Trim() | + | |
| - | + | ||
| - | try { | + | |
| - | $dns = Resolve-DnsName -Name $hostname -Type A -ErrorAction Stop | + | |
| - | $ip = ($dns | Where-Object Type -eq ' | + | |
| - | $parts | + | |
| - | $prefix = " | + | |
| - | $site = if ($SiteMap.ContainsKey($prefix)) { $SiteMap[$prefix] } else { " | + | |
| - | $color | + | |
| - | $SiteCounts[$site] = ($SiteCounts[$site] ?? 0) + 1 | + | |
| - | } catch { | + | |
| - | $ip = $null | + | |
| - | $site = "DNS Lookup Failed" | + | |
| - | $color = "# | + | |
| - | $ErrorCount++ | + | |
| - | } | + | |
| - | + | ||
| - | $Results.Add(@{ Hostname=$hostname; | + | |
| - | $Total++ | + | |
| - | } | + | |
| - | + | ||
| - | $LastUpdated = Get-Date -Format " | + | |
| - | + | ||
| - | # ─── Build summary cards ────────────────────────────────────────────────────── | + | |
| - | $SiteCards = "" | + | |
| - | foreach ($site in $SiteOrder) { | + | |
| - | $count = $SiteCounts[$site] ?? 0 | + | |
| - | if ($count -eq 0) { continue } | + | |
| - | $col = $SiteColors[$site] | + | |
| - | $SiteCards += @" | + | |
| - | + | ||
| - | <div class=" | + | |
| - | <div class=" | + | |
| - | <div class=" | + | |
| - | <div class=" | + | |
| - | </ | + | |
| - | "@ | + | |
| - | } | + | |
| - | + | ||
| - | if ($ErrorCount -gt 0) { | + | |
| - | $SiteCards += @" | + | |
| - | + | ||
| - | <div class=" | + | |
| - | <div class=" | + | |
| - | <div class=" | + | |
| - | <div class=" | + | |
| - | </ | + | |
| - | "@ | + | |
| - | } | + | |
| - | + | ||
| - | # ─── Build table rows ───────────────────────────────────────────────────────── | + | |
| - | $TableRows = "" | + | |
| - | foreach ($r in $Results) { | + | |
| - | $ipHtml = if ($r.IP) { | + | |
| - | "< | + | |
| - | } else { | + | |
| - | "< | + | |
| - | } | + | |
| - | $col = $r.Color | + | |
| - | $TableRows += @" | + | |
| - | + | ||
| - | < | + | |
| - | < | + | |
| - | < | + | |
| - | < | + | |
| - | < | + | |
| - | </ | + | |
| - | "@ | + | |
| - | } | + | |
| - | + | ||
| - | # ─── Write HTML ─────────────────────────────────────────────────────────────── | + | |
| - | $OutDir = Split-Path -Parent $OutputFile | + | |
| - | if (-not (Test-Path $OutDir)) { New-Item -ItemType Directory -Path $OutDir | Out-Null } | + | |
| - | + | ||
| - | @" | + | |
| - | < | + | |
| - | <html lang=" | + | |
| - | < | + | |
| - | <meta charset=" | + | |
| - | <meta name=" | + | |
| - | < | + | |
| - | < | + | |
| - | *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; } | + | |
| - | body { | + | |
| - | font-family: | + | |
| - | background: #0f172a; color: #e2e8f0; | + | |
| - | min-height: 100vh; padding: 2rem 1rem; | + | |
| - | } | + | |
| - | .container { max-width: 960px; margin: 0 auto; } | + | |
| - | header { | + | |
| - | display: flex; align-items: | + | |
| - | flex-wrap: wrap; gap: 1rem; margin-bottom: | + | |
| - | } | + | |
| - | .header-left h1 { font-size: 1.6rem; font-weight: | + | |
| - | .header-left p { font-size: 0.8rem; color: #64748b; margin-top: 0.2rem; } | + | |
| - | .summary { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: | + | |
| - | .card { | + | |
| - | background: #1e293b; border: 1px solid #334155; | + | |
| - | border-radius: | + | |
| - | } | + | |
| - | .card-label { font-size: 0.7rem; text-transform: | + | |
| - | .card-value { font-size: 1.8rem; font-weight: | + | |
| - | .card-sub | + | |
| - | .table-wrap { background: #1e293b; border: 1px solid #334155; border-radius: | + | |
| - | table { width: 100%; border-collapse: | + | |
| - | thead { background: #0f172a; } | + | |
| - | th { | + | |
| - | text-align: left; padding: 0.75rem 1rem; font-size: 0.7rem; | + | |
| - | text-transform: | + | |
| - | } | + | |
| - | td { padding: 0.85rem 1rem; border-top: 1px solid #1e293b; font-size: 0.9rem; vertical-align: | + | |
| - | tr: | + | |
| - | tr:hover td { background: #1d2d45; } | + | |
| - | .hostname { font-weight: | + | |
| - | .friendly { color: #94a3b8; } | + | |
| - | .ip { font-family: | + | |
| - | .ip.failed { color: #f87171; font-style: italic; } | + | |
| - | .badge { display: inline-block; | + | |
| - | .hint { | + | |
| - | margin-top: 1.5rem; background: #1e293b; border: 1px solid #334155; | + | |
| - | border-radius: | + | |
| - | color: #64748b; display: flex; gap: 2rem; flex-wrap: wrap; | + | |
| - | } | + | |
| - | .hint strong { color: #94a3b8; display: block; margin-bottom: | + | |
| - | .hint code { | + | |
| - | background: #0f172a; border: 1px solid #334155; | + | |
| - | padding: 0.1rem 0.4rem; border-radius: | + | |
| - | } | + | |
| - | @media (max-width: 600px) { th: | + | |
| - | </ | + | |
| - | </ | + | |
| - | < | + | |
| - | <div class=" | + | |
| - | < | + | |
| - | <div class=" | + | |
| - | < | + | |
| - | < | + | |
| - | </ | + | |
| - | </ | + | |
| - | <div class=" | + | |
| - | <div class=" | + | |
| - | <div class=" | + | |
| - | <div class=" | + | |
| - | <div class=" | + | |
| - | </ | + | |
| - | $SiteCards | + | |
| - | </ | + | |
| - | <div class=" | + | |
| - | < | + | |
| - | < | + | |
| - | < | + | |
| - | < | + | |
| - | < | + | |
| - | < | + | |
| - | < | + | |
| - | </ | + | |
| - | </ | + | |
| - | < | + | |
| - | $TableRows | + | |
| - | </ | + | |
| - | </ | + | |
| - | </ | + | |
| - | <div class=" | + | |
| - | < | + | |
| - | < | + | |
| - | Edit < | + | |
| - | </ | + | |
| - | < | + | |
| - | < | + | |
| - | Edit < | + | |
| - | </ | + | |
| - | < | + | |
| - | < | + | |
| - | Page regenerated by Task Scheduler — last run shown above | + | |
| - | </ | + | |
| - | </ | + | |
| - | </ | + | |
| - | </ | + | |
| - | </ | + | |
| - | "@ | Set-Content -Path $OutputFile -Encoding UTF8 | + | |
| - | + | ||
| - | Write-Host " | + | |
| - | </ | + | |