Chemin du répertoire de destination
$destinationPath = "C:\certinfo"
Crée le répertoire si nécessaire
if (!(Test-Path -Path $destinationPath)) {
New-Item -ItemType Directory -Path $destinationPath
}
Chemin du magasin de certificats
$certPath = "Cert:\LocalMachine\My"
Récupère les certificats et les copie en fichiers .cer
Get-ChildItem -Path $certPath | ForEach-Object {
$fileName = $.Thumbprint + ".cer"
$filePath = Join-Path -Path $destinationPath -ChildPath $fileName
Export-Certificate -Cert $ -FilePath $filePath
}
Write-Host "Les certificats ont été exportés vers $destinationPath"