A PowerShell extension of Microsoft.Win32.RegistryKey for local and remote registry management
MIT License
The WinRegOps module provides a comprehensive set of PowerShell functions to
interact with the Windows registry, offering a simplified interface for common
operations such as reading, writing, deleting, and exporting registry keys and
values. It extends the functionality of the Microsoft.Win32.RegistryKey
.NET
class and enables local and remote registry operations with enhanced error
handling.
This module is designed to handle registry tasks such as retrieving specific values, managing subkeys, and exporting registry keys. Whether performing configuration management tasks on local machines or managing registry settings across multiple remote systems, WinRegOps simplifies interaction with the Windows registry.
The module can be used independently or as a dependency for higher-level system configuration or management modules, providing flexibility and reliability in registry management operations.
Get-OpenBaseKey
and Get-OpenRemoteBaseKey
.Get-RegistryValue
.New-RegistryKey
, Remove-RegistrySubKey
, and Backup-RegistryKey
.reg.exe
utility, with theExport-RegistryKey
and Invoke-RegCommand
functions.HKEY_LOCAL_MACHINE
andHKEY_CURRENT_USER
.To install WisherTools.Helpers, you have two options:
Install from PowerShell Gallery
You can install the module directly from the PowerShell Gallery
using the Install-Module
command:
Install-Module -Name WinRegOps
Install from GitHub Releases
You can also download the latest release from the GitHub Releases page.
Download the .zip
file of the release, extract it, and place it in one of
your $PSModulePath
directories.
Use the Get-OpenBaseKey
function to open a registry hive on the local machine:
$registryKey = Get-OpenBaseKey -RegistryHive 'HKEY_LOCAL_MACHINE'
This opens the HKEY_LOCAL_MACHINE
hive on the local machine.
The Export-RegistryKey
function allows you to export a registry key to a file
for backup purposes:
Export-RegistryKey -RegistryPath "HKCU\Software\MyApp" -ExportPath "C:\Backup\MyApp.reg"
This exports the registry key HKCU\Software\MyApp
to the file C:\Backup\MyApp.reg
.
Use the Get-OpenRemoteBaseKey
function to open a registry key on a remote
computer:
$registryKey = Get-OpenRemoteBaseKey -RegistryHive 'HKEY_LOCAL_MACHINE' -ComputerName 'RemotePC'
This opens the HKEY_LOCAL_MACHINE
hive on the remote computer RemotePC
.
You can remove a registry subkey using Remove-RegistrySubKey
:
$key = Open-RegistryKey -RegistryPath 'HKLM\Software'
Remove-RegistrySubKey -ParentKey $key -SubKeyName 'MyApp' -WhatIf
This will show what would happen if the MyApp
subkey were deleted without
actually performing the deletion.
The Backup-RegistryKey
function allows you to back up a registry key to a
specified backup directory:
Backup-RegistryKey -RegistryPath 'HKLM\Software\MyApp' -BackupDirectory 'C:\Backups'
This backs up the registry key HKLM\Software\MyApp
to the C:\Backups
directory.
Get-OpenBaseKey
: Opens a registry hive on the local computer. SupportsGet-OpenRemoteBaseKey
: Opens a registry hive on a remote computer.Get-RegistryValue
: Retrieves a specific value from a registry key.Export-RegistryKey
: Exports a registry key to a .reg
file.Invoke-RegCommand
: Executes a registry-related command using the reg.exe
Backup-RegistryKey
: Backs up a registry key from a local or remoteRemove-RegistrySubKey
: Removes a subkey from a specified parent registry-WhatIf
and -Confirm
for safety.Contributions are welcome! Feel free to fork this repository, submit pull requests, or report issues. You can contribute by adding new features, improving the existing code, or enhancing the documentation.