Get Registry Item value – Wildcard

Welcome Forums General PowerShell Q&A Get Registry Item value – Wildcard

Viewing 3 reply threads
  • Author
    Posts
    • #261257
      Participant
      Topics: 12
      Replies: 14
      Points: 92
      Rank: Member

      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

      • This topic was modified 2 weeks, 5 days ago by grokkit.
    • #261275
      Senior Moderator
      Topics: 10
      Replies: 184
      Points: 980
      Helping Hand
      Rank: Major Contributor

      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:

      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:

      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.

    • #261440
      Participant
      Topics: 12
      Replies: 14
      Points: 92
      Rank: Member

      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.

      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

      • This reply was modified 2 weeks, 5 days ago by grokkit. Reason: code formatting - please read the guide
    • #261509
      Senior Moderator
      Topics: 10
      Replies: 184
      Points: 980
      Helping Hand
      Rank: Major Contributor

      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.

      • This reply was modified 2 weeks, 5 days ago by grokkit.
Viewing 3 reply threads
  • You must be logged in to reply to this topic.