Задача импортировать сертификат в личное хранилище компьютера через gpo этого сделать нельзя. Делаю через sccm packages.
Создаем packages
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -File ".\Install-Certificate.ps1"
Сам Код Install-Certificate.ps1
# Computer name
$computerName = $env:COMPUTERNAME
# Start transcript logging
Write-Output "# Start transcript logging"
Start-Transcript -Path "\\путь\transcript_$computerName.txt" -Force
# Path to the certificate file
$certPath = "\\путь\srv.vpnpc.pfx"
#$password = "пароль"
#[Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($password))
# Encoded password in Base64
$encodedPassword = "пароль" # This is "пароль" encoded in Base64
# Decode the password from Base64 and convert it to a secure string
$passwordBytes = [System.Convert]::FromBase64String($encodedPassword)
$passwordPlainText = [System.Text.Encoding]::UTF8.GetString($passwordBytes)
$password = $passwordPlainText | ConvertTo-SecureString -AsPlainText -Force
# Task name in Task Scheduler
#$taskName = "zcdqLcOWMA6X" # Замените на имя вашей задачи
# Check if the certificate exists in the store
Write-Output "# Check if the certificate exists in the store"
$existingCert = Get-ChildItem -Path Cert:\LocalMachine\My | Where-Object { $_.Subject -like "*srv.vpnpc*" }
if ($existingCert) {
Write-Output "The certificate already exists in the store."
} else {
# Import the certificate
Write-Output "# Importing the certificate..."
Import-PfxCertificate -FilePath $certPath -CertStoreLocation Cert:\LocalMachine\My -Password $password
Write-Output "The certificate has been imported successfully."
}
# Remove the scheduled task after successful execution or if the certificate already exists
#try {
# Write-Output "# Removing the scheduled task..."
# Unregister-ScheduledTask -TaskName $taskName -Confirm:$false
# Write-Output "Scheduled task '$taskName' has been removed successfully."
#} catch {
# Write-Warning "Failed to remove the scheduled task. Error: $_"
#}
# Stop transcript logging
Stop-Transcript
Логи на клиенте C:\WINDOWS\CCM\Logs execmgr.log
Similar Posts:
- Как импортировать сертификат для компьютера в личное (personal\my) хранилище сертификатов.
- Как экспортировать и импортировать все запланированные задания (task sheduler) из Windows 2008 r2
- Как обновить сертификат ssl hp ilo через PowerShell и Windows CA
- Как настроить шифрование компьютеров на базе win 10 — 11 в Active Directory с помощью BitLocker , gpo и PowerShell c сохранением ключей
- Как поменять сертификаты на iis для всех сайтов с помощью powershell.



