Skip to content

Instantly share code, notes, and snippets.

@magnuswatn
Last active January 23, 2018 19:13
Show Gist options
  • Save magnuswatn/69545b446abdf6b939bd8e318bb088bb to your computer and use it in GitHub Desktop.
Save magnuswatn/69545b446abdf6b939bd8e318bb088bb to your computer and use it in GitHub Desktop.
<#
Quick script to dump all the issued certs from a Active Directory Certificates Services server
Magnus Watn <[email protected]>
#>
$allCerts = certutil -view -out rawCertificate
$counter = 0
For ($i=0; $i -le $allCerts.length; $i++) {
if ($allCerts[$i] -eq '-----BEGIN CERTIFICATE-----') {
$cert = ""
while ($allCerts[$i] -ne '-----END CERTIFICATE-----') {
$cert += "$($allCerts[$i])`r`n"
$i++
}
$cert += "$($allCerts[$i])`r`n"
$cert | Out-File -Encoding Ascii "$($counter).cer"
$counter++
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment