| Server Migration Dashboard | ||
| 2016 Count: 3 | 2022 Count: 2 | Total Servers: 5 |
| Action Required: Windows Server 2016 | ||
| ARR-01 | Windows 2016 Datacenter | 192.168.2.21 |
| Web-01 | Windows 2016 Datacenter Evaluation | 192.168.3.1 |
| SQL-01 | Windows 2016 Datacenter | 192.168.70.1 |
| Up to date: Windows Server 2022 | ||
| ARR-02 | Windows 2022 Datacenter Evaluation | 192.168.2.22 |
| Web-02 | Windows 2022 Datacenter | 192.168.3.2 |
# 1. Get the data
$ServerList = Get-ADComputer -Filter 'OperatingSystem -like "*Server*" -and Enabled -eq $true' `
-Properties Name, OperatingSystem, IPv4Address |
Select-Object Name, OperatingSystem, IPv4Address
# 2. Split the lists and count
$List2016 = $ServerList | Where-Object { $ .OperatingSystem -like "*2016*" } | Sort-Object Name
$List2022 = $ServerList | Where-Object { $ .OperatingSystem -like "*2022*" } | Sort-Object Name
$totalServers = $ServerList.Count
# 3. HTML Styling
$Header = "<style>
BODY { font-family: 'Segoe UI', sans-serif; padding: 20px; background-color: #f4f4f4; }
H2 { margin-top: 30px; font-size: 1.2em; }
.summary-box { display: flex; gap: 20px; margin-bottom: 10px; }
.stat-card { padding: 10px 20px; background: white; border-radius: 5px; box-shadow: 1px 1px 3px rgba(0,0,0,0.1); }
/* Table Container Styling */
.container-2016 { border: 4px solid #d9534f; border-radius: 8px; padding: 10px; background: white; margin-bottom: 40px; }
.container-2022 { border: 4px solid #5cb85c; border-radius: 8px; padding: 10px; background: white; }
TABLE { border-collapse: collapse; width: 100%; }
TH { text-align: left; padding: 12px; border-bottom: 2px solid #eee; color: #666; font-size: 0.9em; }
TD { padding: 10px; border-bottom: 1px solid #f0f0f0; }
</style>"
# 4. Function to generate table rows
function Get-HtmlRows($List) {
$rows = foreach ($item in $List) {
"<tr><td>$($item.Name)</td><td>$($item.OperatingSystem)</td><td>$($item.IPv4Address)</td></tr>"
}
return $rows -join ""
}
# 5. Assemble the Full Report
$FullHtml = "<html><head>$Header</head><body>
<h1>Server Migration Dashboard</h1>
<div class='summary-box'>
<div class='stat-card'><b style='color:#d9534f'>2016 Count:</b> $($List2016.Count)</div>
<div class='stat-card'><b style='color:#5cb85c'>2022 Count:</b> $($List2022.Count)</div>
<div class='stat-card'><b style='color:#5cb85c'>Total Servers:</b> $totalServers</div>
</div>
</div>
<h2 style='color:#d9534f'>Action Required: Windows Server 2016</h2>
<div class='container-2016'>
<table>
<tr><th>Server Name</th><th>OS</th><th>IP Address</th></tr>
$(Get-HtmlRows $List2016)
</table>
</div>
<h2 style='color:#5cb85c'>Up to Date: Windows Server 2022</h2>
<div class='container-2022'>
<table>
<tr><th>Server Name</th><th>OS</th><th>IP Address</th></tr>
$(Get-HtmlRows $List2022)
</table>
</div>
</body></html>"
# 6. Save and Open
$FilePath = "D:\Server Migration Report.html"
$FullHtml | Out-File $FilePath
Invoke-Item $FilePath