Get Registry Item value - Wildcard

Am trying to get the registry Key value with a wildcard name in it, but it does not show up

Get-ItemPropertyValue ‘HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run’ -Name “Adobe

It does not output any value, even though it has a value as

NYAdobeAll - \ABCD\ServerName

Check your PowerShell version by echoing the contents of $PSVersionTable.
In 5.1 and older, Get-ItemPropertyValue -Name does not accept wildcards.
Wildcards are supported for 6 and up.

You can get around this limitation by piping Get-ItemProperty to Select-Object:

Get-ItemProperty ‘HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run’ | Select-Object "*Adobe*"

This should return an object with the registry value names as properties and the registry value data as values. If there is only one match for “Adobe” then you can get just the data like this:

Get-ItemProperty ‘HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run’ | Select-Object -ExpandProperty "*Adobe*"

which is probably the path that you want. However if there is more than one match then -ExpandProperty won’t be able to handle it and you will have to do some more work to select the specific registry value that you want the data for.

Thanks. Verified and we are using 5.1 Powershell still. So we have multiple entry of Adobe in the registry and am trying to modify each one of them.

$Listreg = (Get-Item -Path 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run').GetValueNames()

$ListReg = $Listreg -Like "*Adobe*"

$abc = Get-ItemPropertyValue 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run' -Name $ListReg
$ModifiReg = $abc -Replace("us01","us02")
Set-ItemProperty 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run' -Name "$ListReg" -Value $ModifiReg

The above code works perfectly if there is only one registry value. But if there are multiple, it does not. Using Foreach also did not work out for me.

Any help is much appreciated

# assign the target registry subkey
$subkey = 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run'

# list registry value names in the target subkey
$Listreg = (Get-Item -Path $subkey).GetValueNames()

# filter the list for the desired application
$ListReg = $Listreg -Like "*Adobe*"

# step through the list and modify each registry value data
foreach ($name in $ListReg) {
    $currentdata = Get-ItemPropertyValue $subkey -Name $name  #get the current registry value data
    $newdata = $currentdata -Replace "us01","us02"            #edit the current value data
    Set-ItemProperty $subkey -Name $name -Value $newdata      #assign the edited data to the registry value
} #foreach name in ListReg

Working from your code and assuming you want to make the same change to each registry value, the above should work (not tested). Also, by storing the registry subkey in a variable it’s faster and easier to write out the script and also makes it easy to apply this to a different subkey if necessary.

For more advanced handling of the registry, I recommend these two articles from 4sysops:
Retrieve the registry keys from remote computers via PowerShell
Create and modify registry keys in remote computers using PowerShell
While it says PowerShell, the method described actually implements the [Microsoft.Win32.RegistryKey]:: .NET class to target the registry directly. It’s a little more flexible and powerful than cmdlets, and you can address the registry of remote systems without mucking around with Invoke-Command and PSRemote. The only real requirements are that the RemoteRegistry service is running and that your credentials are valid on the target system.