Searching registry key, find its property, and replacing the value ?!

touqeeranjum 80 Reputation points
2023-01-31T22:29:22.3266667+00:00

Hi,

I'm going registry because when I do a backup-GPO with Powershell in Windows Server 2022, and restore it in a different server it does not restore the Network Manager List - Network Name Value (which is TEST in this case).

I want to find a registry key, get its property, then replace its value's content.

The command

Get-ChildItem -Recurse 'Registry::\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Group Policy Objects\' | Where-Object -Property Property -eq 'NetworkName'

has the following result (result added to table for clarity)

Hive: \HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Group Policy Objects\HOME.LAB{4EC0F00B-201C-4797-932D-6EF1CC21C6D0}Machine\SOFTWARE\Policies\Microsoft\Windows NT\CurrentVersion\NetworkList\Signatures

Name Property
010103000F0000F0A00000000F0000F086168AABAC5FC2C5CBAB3F047448 CC865A0B7C51543E20F1D32F866F295385D5 NetworkName : TEST
010103000F0000F0A00000000F0000F0B1DB637718FD006EEA6B7AEC531D 8D388D1EA0C6253C23FA568CFED3E89A851E NetworkName : TEST

Hive: \HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Group Policy Objects\HOME.LAB{9F735890-5835-41F2-96DB-41D1A1105B67}Machine\SOFTWARE\Policies\Microsoft\Windows NT\CurrentVersion\NetworkList\Signatures

Name Property
010103000F0000F0A00000000F0000F086168AABAC5FC2C5CBAB3F047448CC865A0B7C51543E20F1D32F866F295385D5 NetworkName : TEST

If I use Get-ItemPropertyValue to get the exact value I can replace the value with Set-ItemProperty but I need to have an absolute path, but the path is dynamic as it contains GUID.

Get-ItemPropertyValue 'Registry::\HKEY_USERS\S-1-5-21-282977542-1070382683-59601606-500\Software\Microsoft\Windows\CurrentVersion\Group Policy Objects\HOME.LAB{4EC0F00B-201C-4797-932D-6EF1CC21C6D0}Machine\SOFTWARE\Policies\Microsoft\Windows NT\CurrentVersion\NetworkList\Signatures\010103000F0000F0A00000000F0000F086168AABAC5FC2C5CBAB3F047448CC865A0B7C51543E20F1D32F866F295385D5' -Name NetworkName

TEST

How to find all keys with a value of TEST, and replace them with my own name ?, the TEST is the value I need to replace.

Thank You

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,549 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,583 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. JIAN WANG 340 Reputation points
    2023-02-01T00:05:52.9533333+00:00

    what if you loop 'Registry::\HKEY_USERS*', and save each GUID,

    then for each one , check if the key you wan exist, if exist , replace it with your own one.

    0 comments No comments

  2. touqeeranjum 80 Reputation points
    2023-02-01T07:40:55.74+00:00

    Thanks for the reply,

    How do I capture the GUID part of it ?


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.