Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a IIS6 web server with 100+ sites on it. Recently, I was forced to renew my wildcard SSL certificate which all the sites use by creating a new CSR request rather than a renew CSR request. I have installed the certificate and can update each site one at a time to use the new certificate however, I was wondering whether:

  1. There is a way to update every site at the same time and
  2. If there was a script I can use to view which certificate is currently being used by each site.
share|improve this question

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
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 
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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.