It is difficult to manage the certificates for websites. When websites hosted on server are large in number task become more tedious and complicated. We have also received similar task for collecting details of certificates for each website on remote server. In our case websites hosted on server were large in number and manually collecting the details for the certificates was time consuming task. So we came up with below PowerShell script which will help us to provide the details.
Script
Import-Module -Name WebAdministration Get-ChildItem -Path IIS:SSLBindings | ForEach-Object -Process ` { if ($_.Sites) { $certificate = Get-ChildItem -Path CERT:LocalMachine/My | Where-Object -Property Thumbprint -EQ -Value $_.Thumbprint [PsCustomObject]@{ Sites = $_.Sites.Value CertificateFriendlyName = $certificate.FriendlyName CertificateIssuer = $certificate.Issuer ExpiryDate = [string]$certificate.NotAfter } } } | ConvertTo-Json | Out-File -Width 4096 C:\ServerCertDetails.json -Append
Above script will provide details of fields for each website hosted on server.
- Website Name
- Certificate Name
- Certificate Issuer
- Certificate Expiry Date
You can customize display details as per your requirement. It will convert the details into json file and save it in specified location.
ServerCertDetails.json
Hope you find this information useful.
No comments:
Post a Comment