Created
October 15, 2018 16:11
-
-
Save ml4den/5ba24a5da34757f804754f24aa45bbe0 to your computer and use it in GitHub Desktop.
Rudimentary PowerShell function for checking host certificate grades using the SSL Labs API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Function Get-HostCertificateGrade ($hostname) { | |
| # Rudimentary function for checking host certificate grades using the SSL Labs API | |
| # https://github.com/ssllabs/ssllabs-scan/blob/master/ssllabs-api-docs-v3.md | |
| Do { | |
| $apiCall = Invoke-RestMethod -Uri "https://api.ssllabs.com/api/v3/analyze?host=$hostname&fromCache=on" | |
| Write-Host $hostname "status:" $apiCall.status | |
| if ($apiCall.status -eq "DNS") {Start-Sleep -Seconds 5} | |
| elseif ($apiCall.status -eq "IN_PROGRESS") {Start-Sleep -Seconds 10} | |
| } Until ($apiCall.status -eq "READY") | |
| Write-Host $hostname "grade:" $apiCall.endpoints.grade | |
| foreach ($endpoint in $apiCall.endpoints) { | |
| $ipAddress = $endpoint.ipAddress | |
| $grade = $endpoint.grade | |
| $functionOutput = @{ | |
| IPAddress = $ipaddress | |
| Grade = $grade | |
| } | |
| New-Object -TypeName PSObject -Property $functionOutput | |
| } | |
| } | |
| $output = Get-HostCertificateGrade -hostname google.com |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment