locked
Reading a reg value ?? RRS feed

  • Question

  • I have this registry key

    HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{EF592782-1817-49A3-9CE0-D4D6F6C248CE}

    under this key are of course many other values, one of which is called DisplayVersion.   No matter what I've tried I can't read this.  I can read ANY value in my registry that does NOT have the curly brackets { }  but once they are there I can't read anything.

    This gives no error and no data

    $Key = "hklm:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{EF592782-1817-49A3-9CE0-D4D6F6C248CE}"
    $ComponentKeys = Get-ChildItem -path $Key 
    $ComponentName = $Components | Select-object DisplayVersion
    $ComponentName

    This code

    $ILE = (get-ItemProperty hklm:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{EF592782-1817-49A3-9CE0-D4D6F6C248CE}).DisplayVersion
    $ILE  

    Says:  

    get-ItemProperty : Property EF592782-1817-49A3-9CE0-D4D6F6C248CE does not exist at path 
    HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\.


    So how do I read this value?

    thank you.


    mqh7


    • Edited by mqh7 Thursday, December 1, 2016 9:12 PM
    Thursday, December 1, 2016 9:11 PM

Answers

  • This is  safer way to do this:

    $Key = 'hklm:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{EF592782-1817-49A3-9CE0-D4D6F6C248CE}'
    if(Test-Path $key){
    	$item = Get-ItemProperty -path $Key -Name DisplayVersion
    	$item.DisplayVersion
    }else{
    	Write-Host 'path not found'
    }
    


    \_(ツ)_/

    • Marked as answer by mqh7 Thursday, December 1, 2016 9:47 PM
    Thursday, December 1, 2016 9:39 PM

All replies

  • Use this script. It will make your life easier.

    Windows IT Pro - Auditing 32-Bit and 64-Bit Applications with PowerShell

    -- Bill Stewart [Bill_Stewart]

    Thursday, December 1, 2016 9:27 PM
  • Thanks I have a similar script.  But it does not help me understand and solve my current problem.  how do I read just the 1 key I need to read?   how come what I did does not work on keys/values that have the curly brackets?  And how do I read a single key/value that does have curly brackets?

    Thank you.  


    mqh7

    Thursday, December 1, 2016 9:31 PM
  • This is  safer way to do this:

    $Key = 'hklm:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{EF592782-1817-49A3-9CE0-D4D6F6C248CE}'
    if(Test-Path $key){
    	$item = Get-ItemProperty -path $Key -Name DisplayVersion
    	$item.DisplayVersion
    }else{
    	Write-Host 'path not found'
    }
    


    \_(ツ)_/

    • Marked as answer by mqh7 Thursday, December 1, 2016 9:47 PM
    Thursday, December 1, 2016 9:39 PM
  • Check both:

    $Key = 'hklm:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{FCC6E820-B5DB-454E-96E3-B6182DDEEC8D}'
    
    $Key = 'hklm:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{EF592782-1817-49A3-9CE0-D4D6F6C248CE}'
    if(Test-Path $key){
    	$item = Get-ItemProperty -path $Key -Name DisplayVersion
    	$item.DisplayVersion
    }else{
    	Write-Host '64 path not found'
    	$Key = 'hklm:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{EF592782-1817-49A3-9CE0-D4D6F6C248CE}'
    	if (Test-Path $key)	{
    		$item = Get-ItemProperty -path $Key -Name DisplayVersion
    		$item.DisplayVersion
    	} else	{
    		Write-Host '32 path not found'
        }
    }
    


    \_(ツ)_/

    Thursday, December 1, 2016 9:46 PM