-
Notifications
You must be signed in to change notification settings - Fork 24
Description
PowerShell/Request-Certificate.ps1
Line 406 in 71ad361
For some certificates you need the whole chain to be exported (For example VMWare vCenter). I adapted your script and maybe you can add it here.
Solution taken from: https://stackoverflow.com/questions/33512409/automate-export-x509-certificate-w-chain-from-server-2008-r2-to-a-p7b-file-witho
New paramter
[Parameter(Mandatory = $False, ValueFromPipelineByPropertyName = $True, ParameterSetName='Export')] [switch]$ExportIncludeAllCerts
New code
$certs = New-Object Security.Cryptography.X509Certificates.X509Certificate2Collection if ($ExportIncludeAllCerts) { $chain = New-Object Security.Cryptography.X509Certificates.X509Chain $chain.ChainPolicy.RevocationMode = "NoCheck" [void]$chain.Build($cert) $chain.ChainElements | ForEach-Object {[void]$certs.Add($_.Certificate)} $chain.Reset() } else { [void]$certs.Add($Certificate) }
Thanks for your code, helped me a lot!