大网数据广告活动
域与目录服务

CA Backup and Restore Windows PowerShell cmdlets

· 52CE 我爱测

Learn more about: CA Backup and Restore Windows PowerShell cmdlets

Author: Justin Turner, Senior Support Escalation Engineer with the Windows group

Note: This content is written by a Microsoft customer support engineer, and is intended for experienced administrators and systems architects who are looking for deeper technical explanations of features and solutions in Windows Server 2012 R2 than topics on TechNet usually provide. However, it has not undergone the same editing passes, so some of the language may seem less polished than what is typically found on TechNet.

Overview

The ADCSAdministration Windows PowerShell module was introduced in Window Server 2012. Two new cmdlets were added to this module in Window Server 2012 R2 to support the Backup and Restore of a CA.

  • Backup-CARoleService

  • Restore-CARoleService

Backup-CARoleService

ADCSAdministration Cmdlet: Backup-CARoleService

Arguments - Bold arguments are required Description
-Path - String - location to save the backup- This is the only unnamed parameter- positional parameter**Example:**Backup-CARoleService.-Path c:\adcsbackup1Backup-CARoleService c:\adcsbackup2
-KeyOnly - Backup the CA certificate without the database**Example:**Backup-CARoleService c:\adcsbackup3 -KeyOnly
-Password - Specifies the password to protect CA certificates and private keys- Must be a secure string- Not valid with the -DatabaseOnly parameterExample:Backup-CARoleService c:\adcsbackup4 -Password (Read-Host -prompt "Password:" -AsSecureString)Backup-CARoleService c:\adcsbackup5 -Password (ConvertTo-SecureString "Pa55w0rd!" -AsPlainText -Force)
-DatabaseOnly - Backup the database without the CA certificateBackup-CARoleService c:\adcsbackup6 -DatabaseOnly
-Force 1. Allows you to overwrite the backup that pre-exists in the location specified in the -Path parameterBackup-CARoleService c:\adcsbackup1 -Force
-Incremental - Perform an incremental backupBackup-CARoleService c:\adcsbackup7 -Incremental
-KeepLog 1. Instructs the command to keep log files. If the switch isn't specified, log files are truncated by default except in the Incremental scenarioBackup-CARoleService c:\adcsbackup7 -KeepLog

-Password <Secure String>

If the -Password parameter is used, the supplied password must be a secure string. Use the Read-Host cmdlet to launch an interactive prompt for secure password entry, or use the ConvertTo-SecureString cmdlet to specify the password in-line.

Review the following examples

Specifying a secure string for the Password parameter using Read-Host

Backup-CARoleService c:\adcsbackup4 -Password (Read-Host -prompt "Password:" -AsSecureString)

Specifying a secure string for the Password parameter using ConvertTo-SecureString

Backup-CARoleService c:\adcsbackup5 -Password (ConvertTo-SecureString "Pa55w0rd!" -AsPlainText -Force)

Restore-CARoleService

ADCSAdministration Cmdlet: Restore-CARoleService

Arguments - Bold arguments are required Description
-Path - String - location to restore backup from- This is the only unnamed parameter- positional parameter**Example:**Restore-CARoleService.-Path c:\adcsbackup1 -ForceRestore-CARoleService c:\adcsbackup2 -Force
-KeyOnly - Restore the CA certificate without the database- Must be specified if the backup was taken with the -KeyOnly option**Example:**Restore-CARoleService c:\adcsbackup3 -KeyOnly -Force
-Password - Specifies the password of the CA certificates and private keys- Must be a secure string**Example:**Restore-CARoleService c:\adcsbackup4 -Password (read-host -prompt "Password:" -AsSecureString) -ForceRestore-CARoleService c:\adcsbackup5 -Password (ConvertTo-SecureString "Pa55w0rd!" -AsPlainText -Force) -Force
-DatabaseOnly - Restore the database without the CA certificateRestore-CARoleService c:\adcsbackup6 -DatabaseOnly
-Force - Allows you to overwrite the preexisting keys- Is an optional parameter but when restoring in-place, it is likely requiredRestore-CARoleService c:\adcsbackup1 -Force

Issues

A nonpassword protected backup is taken if the ConvertTo-SecureString function fails while using the Backup-CARoleService with the -Password parameter.

CA backup and restore

Common errors

Action Error Comment
Restore-CARoleService C:\ADCSBackup Restore-CARoleService : The process can't access the file because it's being used by another process. (Exception from HRESULT:0x80070020) Stop the Active Directory Certificate Services service prior to running the Restore-CARoleService cmdlet
Restore-CARoleService C:\ADCSBackup Restore-CARoleService : The directory isn't empty. (Exception from HRESULT: 0x80070091) Use the -Force parameter to overwrite preexisting keys
Backup-CARoleService C:\ADCSBackup -Password (Read-Host -Prompt "Password:" -AsSecureString) -DatabaseOnly Backup-CARoleService : Parameter set can't be resolved using the specified named parameters. The -Password parameter is only used to password protect private keys and is therefore invalid when you aren't backing them up
Restore-CARoleService C:\ADCSBack15 -Password (Read-Host -Prompt "Password:" -AsSecureString) -DatabaseOnly Restore-CARoleService : Parameter set can't be resolved using the specified named parameters. The -Password parameter is only used to password protect private keys and is therefore invalid when you aren't restoring them
Restore-CARoleService C:\ADCSBack14 -Password (Read-Host -Prompt "Password:" -AsSecureString) Restore-CARoleService : The system can't find the file specified. (Exception from HRESULT: 0x80070002) The path specified doesn't contain a valid database backup. Perhaps the path is invalid or the backup was taken with the -KeysOnly option?

Additional Resources

Active Directory Certificate Services Migration Guide

Backing up a CA database and private key

Restoring the CA database and configuration on the destination server

Try This: Backup the CA in your lab using Windows PowerShell

  1. Use the commands in this lesson to backup the CA database and private key secured with a password.

  2. Hold off on the restore of the CA at this time.

Source: Microsoft Learn / Windows Server documentation by Microsoft and contributors (upstream author metadata: robinharwood). Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Server documentation
适用范围
Windows Server · Source date 05/16/2023
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。