Get only the version number of software from Reg

I am trying to get just the version number from a registry key and it is proving to be very hard. I have this code which works but it will give me the following:

DisplayVersion

5.9.0.21

$VER = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall |
Get-ItemProperty | Where-Object { $_.DisplayName -match “Common.*Core” } | Select-Object -Property displayversion -unique

All I want is the 5.9.0.21 and I don’t want to have to use regular expressions etc… can’t you search for a Display Name and get just the version number from the registry?

Thank you.

When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.

Thanks in advance

How to format code in PowerShell.org 1 <---- Click :point_up_2:t4: :wink:

Either you do

$VER.DisplayVersion

or

$VER = 
    Get-ChildItem -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall' |
        Get-ItemProperty | 
            Where-Object { $_.DisplayName -match 'Common.*Core' } | 
                Select-Object -ExpandProperty DisplayVersion