Created
June 1, 2017 16:29
-
-
Save whereisaaron/d8b97e2f6cd52293db9c12baeba0b001 to your computer and use it in GitHub Desktop.
Export multiple Windows certificates to PFX files
This file contains 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
# | |
# Must run in an Administrator shell to be able to export the keys | |
# Adjust the -Path, Where-Object clauses, and -FilePath to suit | |
# | |
$Password = Read-Host -Prompt "Enter password" -AsSecureString | |
Get-ChildItem -Path cert:\LocalMachine\My | Where-Object -Property FriendlyName -Like "Foo*" | Where-Object -Property Subject -Like "CN=www*" | ForEach-Object { Export-PfxCertificate -FilePath "$($_.FriendlyName) 2017-2018.pfx".Replace(" ","-").ToLower() -Cert $_ -ChainOption BuildChain -Password $Password } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment