PowerShell

Adding Registry Hive HKEY_CURRENT_CONFIG (HKCC) to your PowerShell Drives

Did you know that you can add additional registry hives to your PowerShell drives? No? Then I will show you now how to do that and how to access HKCC with PowerShell. Let’s get started.

Determine PS Drives

Get-PSDrive display all built-in PowerShell Drives.

Get-PSDrive

Some registry hives are missing here. Only HKCU and HKLM are present by default.

Add HKCC (HKey Current Config)

For adding additional drives, all we need to know is how to access them. In this example I use the registry:: statement to access HKCC to add it as a PowerShell drive.

New-PSDrive `
-Name HKCC `
-Root 'registry::HKEY_CURRENT_CONFIG' `
-PSProvider Registry

After all, it’s there and accessible.

Set-Location hkcc:

Have fun accessing the values of the HKCC Hive via PowerShell!

Categories: PowerShell

Tagged as: ,

4 replies »

  1. It’s not as clear as you think. Not only is there no official best practice in the docs, the community is also mostly in favor of splatting instead of backticks.

    https://powershell.org/2013/07/powershell-great-debate-backticks/
    https://github.com/PoshCode/PowerShellPracticeAndStyle/issues/15

    Regardless if you prefer backticks or splatting, chopping up a cmdlet with 3 measly parameters with backticks is NOT good practice. That should be one line.

    Like

  2. Hey have a look at splits

    Those back ticks are doing you zero favours

    And probably not even needed in this case

    Like

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.