Remotely Accessing the Registry using Windows PowerShell

Today I needed to access the registry of a remote computer to find out what Management Groups this agent is part of. That means I needed to find out what Subkeys existed at this path: HKLM\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Agent Management Groups.

 

# $Srv needs to be the name of the Server you want to query.

$Srv = “SERVERNAME”
$key = “SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Agent Management Groups”
$type = [Microsoft.Win32.RegistryHive]::LocalMachine
$regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($type, $Srv)
$regKey = $regKey.OpenSubKey($key)
Foreach($sub in $regKey.GetSubKeyNames()){$sub}

 

Works great, but will require you to have permissions to access the registry remotely (obviously).

 
Comments

Trackbacks for this post

Leave a Reply