1

Using the following PowerShell command,

Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* |
  Select-Object DisplayName, DisplayVersion |
  Select-String 'Application Name'

I get an output like this:

@{DisplayName=Application Name; DisplayVersion=52.4.1521}

If this was on Unix, I could probably figure out a sed or awk command to extract the version number, but on Windows I don't even know where to begin. How do I get that version number out as the value of a variable?

1 Answer 1

2

Get-ChildItem produces a list of objects, so you should work with the properties of those objects. Filter the list via Where-Object for the object with the display name you're looking for, then expand the DisplayVersion property:

$regpath = 'HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall'
$version = Get-ItemProperty "$regpath\*" |
           Where-Object { $_.DisplayName -eq 'Application Name' } |
           Select-Object -Expand DisplayVersion

You can also have the filter do partial matches with wildcards

... | Where-Object { $_.DisplayName -like '*partial name*' } | ...

or regular expressions

... | Where-Object { $_.DisplayName -match 'expression' } | ...
Sign up to request clarification or add additional context in comments.

1 Comment

Wow, this is great. Thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.