Mount-VHDRegistry.ps1
Function Mount-VHDRegistry { <# .SYNOPSIS Mounts the Offline-Registry of a VHD-File .DESCRIPTION Mounts the Offline-Registry of a VHD-File .EXAMPLE Mount-VHDRegistry -DriveLetter E -Tree System Mounts an Offline system-Registry-File into HKLM:\VHD .NOTES Version: 1.0 Author: Holger Voges Date: 2018-08-17 www.netz-weise-it.training/weisheiten/ #> [CmdletBinding(DefaultParameterSetName='Mount')] param( [parameter(Mandatory=$True, ParameterSetName='Mount')] [ValidatePattern("[D-Z,d-z]")] [string]$DriveLetter, [parameter(ParameterSetName='Mount')] [ValidateSet('System','Software')] [string]$Tree = 'System', [parameter(Mandatory=$True, ParameterSetName='DisMount')] [Switch]$Dismount, [string]$RegMountPath = '\vhd' ) $Driveletter = $DriveLetter + ":" $SoftwareKey = join-path -path $Driveletter -childpath '\windows\system32\config\software' $SystemKey = join-path -path $DriveLetter -ChildPath '\windows\system32\config\system' Switch ( $Tree ) { 'System' { $Null = reg.exe load HKLM$RegMountPath $SystemKey } 'Software' { $Null = reg.exe load HKLM$RegMountPath $SoftwareKey } } "HKLM:" + $RegMountPath } |