Hi Luc
Can you help with to fix this below script to generate a html output if there is a table content else write "no license due to expire"
$date = GET-DATE
$htmlformat = '<title>Lic_info</title>'
$htmlformat += '<H1>VMware license forecast notification</H1>'
$htmlformat += '<p>The following report was generated on </p>' + "$date"
$htmlformat += '<style type="text/css">'
$htmlformat += 'BODY{background-color:#E5E8E8 ;color:#000000;font-family:Arial Narrow,sans-serif;font-size:12px;}'
$htmlformat += 'TABLE{border-width: 3px;border-style: solid;border-color: black;border-collapse: collapse;}'
$htmlformat += 'TH{border-width: 1px;padding: 3px;border-style: solid;border-color: black;background-color:#FCF3CF}'
$htmlformat += 'TD{border-width: 1px;padding: 6px;border-style: solid;border-color: black;background-color:#CACFD2}'
$htmlformat += '</style>'
$bodyformat = '<h1> VMware Environment </h1>'
$html = Import-Csv -delimiter ',' -Path "F:\\licdetails.txt" | Select EntityDisplayName,Name,LicenseKey,EditionKey,ProductName,ProductVersion,ExpirationDate,DaysToExpiration | Sort-Object DaysToExpiration | where-object {($_.DaysToExpiration -ne "na") } |
if($_.DaysToExpiration -match "^\d+$")
convertTo-Html -Head $htmlformat -Body {} else {Write-Host "<h1>No licenses due to expire</h1>"}
$html | Out-File F:\VMware_Environment_license_notification.html
Invoke-Expression F:\VMware_Environment_license_notification.html