Skip to main content

How to Access all of the Registry Hives with PowerShell

In Windows PowerShell, there is a PSProvider called Registry.  By default, it gives you access to two registry hives.

PS C:\> Get-PSDrive -PSProvider Registry

 

Name         Used (GB)     Free (GB) Provider      Root                                               CurrentLocation

----         ---------     --------- --------     ------------------

HKCU                                 Registry     HKEY_CURRENT_USER

HKLM                                 Registry     HKEY_LOCAL_MACHINE                                                   

 

 

There are actually 5 registry hives.

  • HKEY_CLASSES_ROOT
  • HKEY_CURRENT_USER
  • HKEY_LOCAL_MACHINE
  • HKEY_USERS
  • HKEY_CURRENT_CONFIG

According to Microsoft, here are their intended purposes in life. (http://support.microsoft.com/kb/256986)

Folder/predefined key Description
HKEY_CURRENT_USER Contains the root of the configuration information for the user who is currently logged on. The user's folders, screen colors, and Control Panel settings are stored here. This information is associated with the user's profile. This key is sometimes abbreviated as "HKCU."
HKEY_USERS Contains all the actively loaded user profiles on the computer. HKEY_CURRENT_USER is a subkey of HKEY_USERS. HKEY_USERS is sometimes abbreviated as "HKU."
HKEY_LOCAL_MACHINE Contains configuration information particular to the computer (for any user). This key is sometimes abbreviated as "HKLM."
HKEY_CLASSES_ROOT Is a subkey of HKEY_LOCAL_MACHINE\Software. The information that is stored here makes sure that the correct program opens when you open a file by using Windows Explorer. This key is sometimes abbreviated as "HKCR." Starting with Windows 2000, this information is stored under both the HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER keys. The HKEY_LOCAL_MACHINE\Software\Classes key contains default settings that can apply to all users on the local computer. The HKEY_CURRENT_USER\Software\Classes key contains settings that override the default settings and apply only to the interactive user. The HKEY_CLASSES_ROOT key provides a view of the registry that merges the information from these two sources. HKEY_CLASSES_ROOT also provides this merged view for programs that are designed for earlier versions of Windows. To change the settings for the interactive user, changes must be made under HKEY_CURRENT_USER\Software\Classes instead of under HKEY_CLASSES_ROOT. To change the default settings, changes must be made under HKEY_LOCAL_MACHINE\Software\Classes. If you write keys to a key under HKEY_CLASSES_ROOT, the system stores the information under HKEY_LOCAL_MACHINE\Software\Classes. If you write values to a key under HKEY_CLASSES_ROOT, and the key already exists under HKEY_CURRENT_USER\Software\Classes, the system will store the information there instead of under HKEY_LOCAL_MACHINE\Software\Classes.
HKEY_CURRENT_CONFIG Contains information about the hardware profile that is used by the local computer at system startup.

The registry provider gives you access to the three unlisted hives: HKEY_CLASSES_ROOT, HKEY_USERS, and HKEY_CURRENT_CONFIG.  You just have to manually create a drive to them.

 

New-PSDrive -PSProvider registry -Root HKEY_CLASSES_ROOT -Name HKCR

New-PSDrive -PSProvider registry -Root HKEY_USERS -Name HKU

New-PSDrive -PSProvider registry -Root HKEY_CURRENT_CONFIG -Name HKCC

 

Once you do, you will have access to these hives just the two default drives the registry provider gives you.

PS C:\> Get-PSDrive -PSProvider Registry

 

Name       Used (GB)     Free (GB) ProviderRoot

----       ---------     --------- --------     ---- 

HKCC                               Registry     HKEY_CURRENT_CONFIG                                   

HKCR                               Registry     HKEY_CLASSES_ROOT                                     

HKCU                               Registry     HKEY_CURRENT_USER                                     

HKLM                               Registry     HKEY_LOCAL_MACHINE                             

HKU                                Registry     HKEY_USERS                                           

 

 

 

Comments

Popular posts from this blog

How to force a DNS zone to replicate

For many implementations of DNS in a Windows environment, DNS is configured as being Active Directory integrated.  In other words, the DNS zone information is actually stored as a partition in the active directory database.  When Active Directory replicates, the zone data transfers.  For standard DNS deployments, the data is stored in a file.  You have to configure zone transfers manually in the DNS console.The question in class was how to initiate replication manually.  Once you have properly configured a Primary and secondary DNS server and configured the Primary server to allow zone transfers, you can manually initiate a zone transfer.Below you can see our test environment.  The image is of to RDP sessions to two different servers.  The DNS console on the left is the primary.  You can see and entry for Test2 that is not in the secondary database.  The servers are named NYC-DC2 (Primary DNS) and NYC-DC1 (Secondary DNS).  The DNS zone is named test.contoso.com.On the secondary server…

Determine which Domain Controller a client is connected to with PowerShell

When a Windows client comes online, it must find a domain controller to bind to.  Either through a static configuration or DHCP, the client will request a list of all Domain Controllers in the domain from a DNS server.  Once the list is received, the client will randomly go through the list to find a DC that will respond.  Once the client has authenticated itself with the DC, the DC will transmit the site information to the client.  The site information will contain the site name, the subnet(s) associated with that site, and any domain controllers in that site.  The client will then take a look at it’s own IP address to determine which site it is in.  From the list of DCs in the same site, it will attempt to bind to one of those DCs to receive it’s Group Policies.You can use PowerShell and WMI to locate the domain controller that a client is connected to.Get-WMIObject Win32_NTDomainLook for the DomainControllerName property.

Export Your Performance Monitor Data to Excel

Updated: 2016MAY04

To clarify when this functionality is available, you can only save the view when you are viewing a Data Collection Set.  The "live" data cannot be saved in this way.

Performance Monitor in Windows Server give us the ability to see when our servers are having some issues.  Analyzing that data into something meaningful can be a problem.  You can export your data to Excel so you can better see what your performance data represents. 
First collect your data.

Right click the graph and select Save Data As.
Change the Save as type to Text file (comma delimited)(*.csv).
Give the file a name and save it where you want to store it.
Now open that file on a client with Excel installed on it.  By using excel, you will be able to present the data in a more meaningful format.