$backup = "$env:USERPROFILE\Documents\EFS_LR5_Backup\EFS_Key.PFX"
if (-not (Test-Path $backup)) {
throw "PFX backup not found! STOP."
}
$password = Read-Host "Enter PFX password" -AsSecureString
$data = Get-PfxData -FilePath $backup -Password $password -ErrorAction Stop
$cert = $data.EndEntityCertificates | Select-Object -First 1
if (-not $cert) {
throw "No certificate in PFX! STOP."
}
$installed = Get-Item "Cert:\CurrentUser\My\$($cert.Thumbprint)" -ErrorAction SilentlyContinue
if (-not $installed -or -not $installed.HasPrivateKey) {
throw "Certificate mismatch or local private key missing! STOP."
}
Write-Host "`nBACKUP VERIFIED" -ForegroundColor Green
Write-Host "Certificate:" $cert.Subject
Write-Host "Thumbprint:" $cert.Thumbprint
Write-Host "Local private key:" $installed.HasPrivateKey
cipher /c "C:\Users\Public\Documents\EFS_LR5\File_1.txt"
Get-Content "C:\Users\Public\Documents\EFS_LR5\File_1.txt"
$backup = "$env:USERPROFILE\Documents\EFS_LR5_Backup\EFS_Key.PFX"
$password = Read-Host "Введите пароль от сертификата" -AsSecureString
Import-PfxCertificate -FilePath $backup -CertStoreLocation "Cert:\CurrentUser\My" -Password $password
Get-Content "C:\Users\Public\Documents\EFS_LR5\File_1.txt"