I have an answer for the second item for those that are interested. Create a text file with the contents below and save it with a .vbs
extention. Then execute it with cscript myfile.vbs
from the command-line. If you execute it as cscript myfile.vbs > output.txt
it will put the results in a text file.
strComputer = "localhost"
Set objService = GetObject( "IIS://" & strComputer & "/W3SVC")
EnumServersites objService
Public Sub EnumServersites( objSrv )
For Each objServer IN objSrv
If objServer.Class = "IIsWebServer" Then
If Not Ubound(objServer.SecureBindings) = "-1" Then 'check to see if there is at least one securebinding
WScript.Echo "Site ID = " & objServer.Name & VbCrLf & "Comment = """ & objServer.ServerComment
wscript.Echo "SSL Certificate Expiration Date: " & GetSSLExpirationDate(objServer.Name)
wscript.Echo "Days Remaining: " & DaysRemaining(GetSSLExpirationDate(objServer.Name))
wscript.echo vbcrlf & "-----------------------------" & vbcrlf
End If
End If
strBindings = vbNullString
Next
End Sub
Private Function GetSSLExpirationDate( strSiteID )
Set iiscertobj = WScript.CreateObject("IIS.CertObj")
iiscertobj.serverName = "localhost"
iiscertobj.InstanceName = "W3SVC/" & strSiteID
tmpArray = Split(iiscertobj.GetCertInfo,vbLf)
For Each x in tmpArray
If Left(x,2) = "6=" Then
GetSSLExpirationDate = Mid(x,3,len(x)-2)
End If
Next
End Function
Private Function DaysRemaining(strdate)
If IsDate(strDate) Then
strdate = cDate(strdate)
End If
DaysRemaining = DateDiff("d",Date,strdate)
End Function
I pulled this script from here.