Powershell Microsoft.win32.registrykey Openremotebasekey Credentials

I was reading the news groups (as I do all the time) and I have notice numerous request/questions regarding remote registry access in powershell. I thought I would try to see if I could shed some light on the subject. So without further delay... on with the show!
Overview:
----------

Powershell Microsoft.win32.registrykey Openremotebasekey Credentials Rating: 4,4/5 641 reviews I'm trying to write an application that will get some registry values from a remote computer. The user can provide a hostname or IP in a string and should be getting a registry value displayed on their screen. Today I had a need to query the default value of a registry key in remote computer. There are several articles on internet which are talking about reading default value of a registry key from local machine but no one has enough information about reading default value of registry from remote computer. Hi, I am trying to recurse through a remote registry key path and search through it for a value name and get the value data.Hence i need to give it atleast a subkey to start from so as to avoid searching time delay through many nodes.

Dismiss Join GitHub today. GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together. Solution: Just a guess, but is the Remote Registry service started on the remote computers? If not, this won't work. Try running:Get-Service -ComputerName.


Registry access in Posh is realatively simple and extremely powerful.
From a local stand point its as simple as:
PS> Set-Location HKLM:System
From a remote standpoint... you have to utilize the powers of .NET.
$ServerKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine, ServerName)
For the purpose of this post... I am going to focus on the remote aspect. Local is cover in tons of documentation. So, cause of time, I am only going to address the .NET method.
I will start by giving you the Remote Registry Object useful Properties/MethodsPowershell
Object
-------
[Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine,MachineName)
Properties
-------------
Name
SubKeyCount
ValueCount

Methods (Not all.. just the ones I use often)
---------------------------------------------------
CreateSubKey
DeleteSubKey
DeleteSubKeyTree
DeleteValue
GetAccessControl
GetLifetimeService
GetSubKeyNames
GetType
GetValue
GetValueKind
GetValueNames
OpenSubKey
SetAccessControl
SetValue

As you can see... You can do basically everything you could ever want.
Now that you have a basic idea of what the .NET provider can give you... let put it to practical use.
Examples:
----------
Purpose: Get a list of Subkeys and Values of Specific Registry Key.
Result (only showing first 10 of each:)
Sub Keys
--------
App Management
App Paths
Applets
BITS
Control Panel
Controls Folder
CSCSettings
DateTimeDynamic
DirectoryExplorer
Values
------
DevicePath
MediaPath
Unexpanded
SM_GamesName
SM_Configure
ProgramsName
ProgramFilesDir
CommonFilesDir
ProductId
WallPaperDir
MediaPath
ProgramFilesPath
-------------------------------------------
Purpose: Get the Value of each of the Values.
Result (only showing first 10:)
Values
------
DevicePath = [C:WINDOWSinf;C:DriversBroadcomWin2003]
MediaPathUnexpanded = [C:WINDOWSMedia]
SM_GamesName = [Games]
SM_ConfigureProgramsName = [Set Program Access and Defaults]
ProgramFilesDir = [C:Program Files]
CommonFilesDir = [C:Program FilesCommon Files]
ProductId = [69713-640-4031427-45876]
WallPaperDir = [C:WINDOWSWebWallpaper]
MediaPath = [C:WINDOWSMedia]
ProgramFilesPath = [C:Program Files]
------------------------------------------------
Summary:
-----------
As you now can see. POSH is really powerful given its .NET access to the registry. Honestly... there is virtually nothing you can't do and its easy to boot. You have complete access to Registry keys/subkeys/values. You can even Create, Delete, and evaluate Values and keys. In the future I will be sharing a function I wrote to compare Registry Subkeys between machines. That has proven to be super valuable.
Well... That about does it (at least for today :) ) I think this is a pretty good start to your POSH .NET registry adventure. I will be expanding this as I have time.
As always... PLEASE PROVIDE FEEDBACK!!! :)I was reading the news groups (as I do all the time) and I have notice numerous request/questions regarding remote registry access in powershell. I thought I would try to see if I could shed some light on the subject. So without further delay... on with the show!
Overview:
----------
Registry access in Posh is realatively simple and extremely powerful.
From a local stand point its as simple as:
PS> Set-Location HKLM:System
From a remote standpoint... you have to utilize the powers of .NET.
$ServerKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine, ServerName)
For the purpose of this post... I am going to focus on the remote aspect. Local is cover in tons of documentation. So, cause of time, I am only going to address the .NET method.
I will start by giving you the Remote Registry Object useful Properties/Methods
Object
-------
[Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine,MachineName)
Properties
-------------
Name
SubKeyCount
ValueCount

Methods (Not all.. just the ones I use often)
---------------------------------------------------
CreateSubKey
DeleteSubKey
DeleteSubKeyTree
DeleteValue
GetAccessControl
GetLifetimeService
GetSubKeyNames
GetType
GetValue
GetValueKind
GetValueNames
OpenSubKey
SetAccessControl
SetValue

As you can see... You can do basically everything you could ever want.
Now that you have a basic idea of what the .NET provider can give you... let put it to practical use.
Examples:
----------
Purpose: Get a list of Subkeys and Values of Specific Registry Key.
Result (only showing first 10 of each:)
Sub Keys
--------
App Management
App Paths
Applets
BITS
Control Panel
Controls Folder
CSCSettings
DateTimeDynamic
DirectoryExplorer
Values
------
DevicePath
MediaPath
Unexpanded
SM_GamesName
SM_Configure
ProgramsName
ProgramFilesDir
CommonFilesDir
ProductId
WallPaperDir
MediaPath
ProgramFilesPath
-------------------------------------------
Purpose: Get the Value of each of the Values.
Result (only showing first 10:)
Values
------Openremotebasekey
DevicePath = [C:WINDOWSinf;C:DriversBroadcomWin2003]
MediaPathUnexpanded = [C:WINDOWSMedia]
SM_GamesName = [Games]
SM_ConfigureProgramsName = [Set Program Access and Defaults]
ProgramFilesDir = [C:Program Files]

C# Registrykey Class


CommonFilesDir = [C:Program FilesCommon Files]
ProductId = [69713-640-4031427-45876]

Openremotebasekey Powershell

WallPaperDir = [C:WINDOWSWebWallpaper]
MediaPath = [C:WINDOWSMedia]
ProgramFilesPath = [C:Program Files]
------------------------------------------------
Summary:
-----------
As you now can see. POSH is really powerful given its .NET access to the registry. Honestly... there is virtually nothing you can't do and its easy to boot. You have complete access to Registry keys/subkeys/values. You can even Create, Delete, and evaluate Values and keys. In the future I will be sharing a function I wrote to compare Registry Subkeys between machines. That has proven to be super valuable.
Well... That about does it (at least for today :) ) I think this is a pretty good start to your POSH .NET registry adventure. I will be expanding this as I have time.

Powershell Openbasekey

As always... PLEASE PROVIDE FEEDBACK!!! :)