Skip to main content

Backup-RegistryValue

Overview

This script will create a backup of a registry item either specifically or recursively to HKLM:\Software\_automation\RegistryBackup.

For instance, if backing up the key Windowsversion found in HKLM:\Software\_automation\WindowsUpdate, the backed-up key will be found in HKLM:\SOFTWARE\_automation\RegistryBackup\HKLM\Software\_automation\WindowsUpdate\Windowsversion.

Requirements

This script requires administrative rights to read and write in the registry.

Process

  1. Gets needed information for the key properties (or keys and all associated properties) being backed up.
  2. Formats a new path for the backup using the standard HKLM:\Software\_automation\RegistryBackup (HKLM, HKCU, HKU, etc.) followed by the remainder of the given origin path.
  3. Saves a copy of that key to the new location.
  4. Verifies that the copied key is identical to the original key.

Payload Usage

Backup-RegistryValue.ps1 -Path 'HKLM:\Software\_automation\WindowsUpdate' -KeyName Windowsversion

Creates a copy of the key HKLM:\Software\_automation\WindowsUpdate\Windowsversion to HKLM:\SOFTWARE\_automation\RegistryBackup\HKLM\Software\_automation\WindowsUpdate\Windowsversion.

Backup-RegistryValue.ps1 'HKLM:\SOFTWARE\Microsoft\DataAccess'

Creates a copy of the key HKLM:\Software\Microsoft\DataAccess and all its subkeys recursively to HKLM:\SOFTWARE\_automation\RegistryBackup\HKLM\Software\Microsoft\DataAccess.

Parameters

ParameterAliasRequiredDefaultTypeDescription
-PathTrueStringThe path of the key you wish to backup.
-NameTrueStringHolds the key name for the desired backup specific key (omit for recursive backup).

Output

.\Backup-RegistryValue-log.txt
.\Backup-RegistryValue-error.txt

Locations

Payload
/repo/script/Backup-RegistryValue.ps1
Automate
ConnectWise RMM
Kaseya
Datto RMM