Internetopties > Inhoud > Certificaten > Export
Volgende > Ja persoonlijke sleutel exporteren > Volgende
Alle uitgebreide eigenschappen exporteren + Certificaat privacy uitschakelen
Volgende > Wachtwoord > Pass > Pass > Volgende
Bladeren > Opslaan > Volgende > Voltooien > OK
List My Certificates (Non expired):
Get-ChildItem -Path Cert:\CurrentUser\My | Where-Object {$_.NotAfter -gt (Get-Date)} | Select-Object @{Name='Subject';Expression={if ($_.Subject -match "CN=([^,]+)") {$matches[1]} else {$_.Subject.Substring(0, [Math]::Min(60, $_.Subject.Length))}}}, @{Name='Issuer';Expression={if ($_.Issuer -match "CN=([^,]+)") {$matches[1]} else {$_.Issuer.Substring(0, [Math]::Min(60, $_.Issuer.Length))}}}, @{Name='Thumbprint';Expression={$_.Thumbprint}}, @{Name='Expires';Expression={$_.NotAfter.ToString("yyyy-MM-dd")}} | Format-Table -Wrap
List My Certificates (All):
Get-ChildItem -Path Cert:\CurrentUser\My | Select-Object @{Name='Subject';Expression={if ($_.Subject -match "CN=([^,]+)") {$matches[1]} else {$_.Subject.Substring(0, [Math]::Min(60, $_.Subject.Length))}}}, @{Name='Thumbprint';Expression={$_.Thumbprint}}, @{Name='Expires';Expression={$_.NotAfter.ToString("yyyy-MM-dd")}} | Format-Table -Wrap
Export VECOZO - G4 - Password 1234:
$certs = Get-ChildItem -Path Cert:\CurrentUser\My | Where-Object {$_.NotAfter -gt (Get-Date) -and $_.Issuer -match "CN=VECOZO - G4"}; $password = ConvertTo-SecureString -String "1234" -Force -AsPlainText; foreach ($cert in $certs) { $safeSubject = $(if ($cert.Subject -match "CN=([^,]+)") {$matches[1]} else {$cert.Subject.Substring(0, [Math]::Min(60, $cert.Subject.Length))}) -replace '[\\\/\:\*\?\"\<\>\|]', '_'; Export-PfxCertificate -Cert $cert -FilePath "$(Get-Location)\$safeSubject.pfx" -Password $password }
Export Certificate:
$thumbprint = "YOUR_THUMBPRINT_HERE"
$password = "password"
$downloadsFolder = [Environment]::GetFolderPath("UserProfile") + "\Downloads"
$exportPath = Join-Path -Path $downloadsFolder -ChildPath "exported_cert.pfx"
$securePassword = ConvertTo-SecureString -String $password -Force -AsPlainText
$cert = Get-ChildItem -Path Cert:\CurrentUser\My\$thumbprint
Export-PfxCertificate -Cert $cert -FilePath $exportPath -Password $securePassword
Import Certificate:
$password = "password"
$downloadsFolder = [Environment]::GetFolderPath("UserProfile") + "\Downloads"
$certPath = Join-Path -Path $downloadsFolder -ChildPath "exported_cert.pfx"
function Import-P12Certificate {
param(
[String]$certPath,
[String]$certRootStore = "CurrentUser",
[String]$certStore = "My",
$pfxPass = $null
)
if ($pfxPass -eq $null) {
$pfxPass = read-host "Enter the pfx password" -assecurestring
}
# Create certificate object with the correct constructor
$pfx = new-object System.Security.Cryptography.X509Certificates.X509Certificate2($certPath, $pfxPass, [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::Exportable)
$store = new-object System.Security.Cryptography.X509Certificates.X509Store($certStore, $certRootStore)
$store.open("MaxAllowed")
$store.add($pfx)
$store.close()
}
Import-P12Certificate $certPath CurrentUser My $password