Hi luc ,
can yu please check html command to get proper output .
$path1 = 'D:\hc'
$path = "D:\hc\compliance-$(Get-Date -Format 'yyyyMMdd-HHmm').html"
#(get-credential).password | ConvertFrom-SecureString | set-content "$path1\password.txt"
$password = Get-Content "$path1\password.txt" | ConvertTo-SecureString
$credential = New-Object System.Management.Automation.PsCredential("administrator@vsphere.local",$password)
connect-viserver -server "vcenter01" -Credential $credential
$head = @'
<style>
body { background-color:#dddddd;
font-family:Tahoma;
font-size:12pt; }
td, th { border:1px solid black;
border-collapse:collapse; }
th { color:white;
background-color:black; }
table, tr, td, th { padding: 2px; margin: 0px }
table { margin-left:50px; }
</style>
'@
$esxi=get-vmhost
$deviated_esxi=@()
foreach($e in $esxi)
{
$v=get-vmhost -Name $e
$accountunlocktime_minutes=(Get-AdvancedSetting -Entity $v -Name Security.AccountUnlockTime).value/60
if($accountunlocktime_minutes -ne "60"){
[PSCustomObject]@{
esxinmae = $v
accountunlocktime_minutes=$accountunlocktime_minutes
}
$deviated_esxi += $v
}
}
$deviated_esxi|ConvertTo-Html -Property name -Fragment -PreContent '<h2>esxiwithlockdowntime not60mins </h2>' |
Out-String
ConvertTo-HTML -head $head -PostContent $deviated_esxi |
Out-String | Out-File -FilePath $path