Web page to report all Expired and Expiring Certificates on the network

Welcome Forums General PowerShell Q&A Web page to report all Expired and Expiring Certificates on the network

Viewing 0 reply threads
  • Author
    Posts
    • #223881
      Participant
      Topics: 2
      Replies: 1
      Points: -6
      Rank: Member
      <######################################################################
      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 += "
      <p><u>SERVERS SSL CERTIFICATE STATUS REPORT</u></p>
      " $HTML += "
      <button onclick='goBack()'>HOME</button>
      " $HTML += "<br><br>" $HTML += "
      " $HTML += "" Foreach($Entry in $Result) { $HTML += " " } $HTML += "
      Server Name Days to Exp. Date Exp. Thumb Print Serial
      $($Entry.ServerName) $($Entry.DaystoExp) $($Entry.DateExp) $($Entry.ThumbPrint) $($Entry.Serial)
      </br></br></br>" Write-Output $HTML }
Viewing 0 reply threads
  • You must be logged in to reply to this topic.