title: Powershell list ftp certificate thumbprint
body: <p>I'm in the process of using powershell to audit certificate expiry.</p>
  
  <p>One of the areas we're looking at is IIS site bindings inclusing FTP.</p>
  
  <p>Now when I list out IIS sites, retrieve the thumbprint and then match with a certificate, it appears no FTP site information is pulled out...</p>
  
  <pre><code>$DaysToExpiration = 7
  
  $expirationDate = (Get-Date).AddDays($DaysToExpiration)
  
  $sites = Get-Website | ? { $_.State -eq "Started" } | % { $_.Name }
  $certs = Get-ChildItem IIS:SSLBindings | ? {
             $sites -contains $_.Sites.Value
           } | % { $_.Thumbprint }
  
  Get-ChildItem CERT:LocalMachine/My | ? {
    $certs -contains $_.Thumbprint -and $_.NotAfter -lt $expirationDate
  }
  </code></pre>
  
  <p>The above does list the FTP site in the $sites variable but only the web site(s) SSL details are ever listed...</p>
  
  <p>When certificates are added to an FTP site it's not performed in the same way as with at web site and I'm guessing this is the reason that no SSL details for the FTP site is extracted.</p>
  
  <p>Does anyone know how to get at the thumbprint of the cert bound to an FTP site in powershell?</p>
  
  <p>Thanks,</p>
  
  <p>James</p>