Skip to content

Instantly share code, notes, and snippets.

@ashtewari
Last active October 6, 2022 13:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ashtewari/31ce67d89b1878db52ca7558dbb3e194 to your computer and use it in GitHub Desktop.
Save ashtewari/31ce67d89b1878db52ca7558dbb3e194 to your computer and use it in GitHub Desktop.
$header = @"
<style>
h1 {
font-family: Arial, Helvetica, sans-serif;
color: #296940;
font-size: 28px;
}
h2 {
font-family: Arial, Helvetica, sans-serif;
color: #49708f;
font-size: 16px;
}
table {
font-size: 12px;
border: 0px;
font-family: Arial, Helvetica, sans-serif;
}
td {
padding: 4px;
margin: 0px;
border: 0;
}
th {
background: #49708f;
background: linear-gradient(#49708f, #296940);
color: #fff;
font-size: 11px;
text-transform: uppercase;
padding: 10px 15px;
vertical-align: middle;
}
tbody tr:nth-child(even) {
background: #f3f3fa;
}
#CreationDate {
font-family: Arial, Helvetica, sans-serif;
color: #ff3300;
font-size: 12px;
}
.OkStatus {
color: #3fd15e;
}
.WarningStatus {
color: #ff8f04;
}
</style>
"@
$aksVersionsJson = az aks get-versions --location eastus
$aksVersions = $aksVersionsJson | ConvertFrom-Json
$aksVersions.orchestrators.upgrades.orchestratorVersion
$data = $aksVersions.orchestrators | Select-Object `
-Property @{Name="Version";Expression={$_.orchestratorVersion}} `
, @{Name="Default";Expression={$_.default}} `
, @{Name="Preview";Expression={$_.isPreview}} `
, @{Name="Upgrades";Expression={$_.upgrades.orchestratorVersion -join ", "}}
$versionTable = $data | ConvertTo-Html -Fragment
$versionTableString = $versionTable | Out-String
$html = New-Object -ComObject "HTMLFile"
$html.IHTMLDocument2_write($versionTableString)
$tables = $html.body.getElementsByTagName("table")
$rptString = ""
ForEach($table in $tables){
ForEach($row in $table.rows){
$cellCount = 0
ForEach($cell in $row.cells){
$cellCount++
if(($cellCount -eq 2) -and ($cell.innertext -eq 'True'))
{
$row.className = "OkStatus"
}
if(($cellCount -eq 3) -and ($cell.innertext -eq 'True'))
{
$row.className = "WarningStatus"
}
}
}
$rptString += $table.outerHTML
}
$reportDate = $(get-date -DisplayHint DateTime) | Out-String
$fileTS = $(get-date -Format "yyyyMMdd")
$fileName = "aks-versions-$fileTS.html"
$rptTitle = "<h1>AKS Kubernetes Versions</h1><p>$reportDate</p>"
$report = ConvertTo-Html -Title "AKS Versions" -Body "$rptTitle $rptString" -Head $header
$report | Out-File "$fileName"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment