ebaad
1
<######################################################################
SERVER SSL CERT STATUS REPORT
This Script gathers the report of SSL CERTIFICATES installed
and generates HTML output.
.NOTES
Name: get_cert-date-SERVERS.ps1
Version : 1.1
Date : 04-Apr-2020
.ServerList
Add List of Servers in SERVERS.txt file and keep on same directory
.EXAMPLE
get_cert-date-SERVERS.ps1
######################################################################>
$InputFIle = "C:\wamp64\apps\uptime\SERVERS.txt"
$Computers = Get-Content $InputFIle -ReadCount 0
$Result = @()
foreach ($ServerName in $Computers){
$FullName = "$Servername.maringeneral.org"
$Certs = invoke-command -ComputerName $FullName -ScriptBlock {Get-ChildItem Cert:\LocalMachine\My}
foreach($certificate in $Certs){
$Machine = $ServerName
$DateExp = $certificate.NotAfter
$DaystoExp = ($certificate.NotAfter - (Get-Date)).Days
$TP = $certificate.ThumbPrint
$Serial = $certificate.SerialNumber
$Result += New-Object PSObject -Property @{
ServerName = $Machine
DateExp = $DateExp
DaystoExp = $DaystoExp
ThumbPrint = $TP
Serial = $Serial
}
}
}
$TodayTime = Get-Date -DisplayHint DateTime
#---------------------
# Generate HTML report page
#------------------------
if($Result -ne $null)
{
$HTML = "<p>
Time : $TodayTime <br>
</p>"
$HTML += "<div class="script-name"><p><u>SERVERS SSL CERTIFICATE STATUS REPORT</u></p></div>"
$HTML += "<div class="script-name"><button onclick='goBack()'>HOME</button></div>"
$HTML += "<br><br>"
$HTML += "<div>"
$HTML += "<Table class="'sortable'">
<TR>
<TH><B>Server Name</B></TH>
<TH><B>Days to Exp.</B></TH>
<TH><B>Date Exp.</B></TH>
<TH><B>Thumb Print</B></TD>
<TH><B>Serial</B></TH>
</TR>"
Foreach($Entry in $Result)
{
$HTML += "
<TR>
<TD>$($Entry.ServerName)</TD>
<TD>$($Entry.DaystoExp)</TD>
<TD>$($Entry.DateExp)</TD>
<TD>$($Entry.ThumbPrint)</TD>
<TD>$($Entry.Serial)</TD>
</TR>"
}
$HTML += "</Table></div></br></br></br>"
Write-Output $HTML
}