4

How can I club these two ?

Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*|`
Where-Object {$_.displayname -like "*Database Engine Services*" } |  Select-Object DisplayName, DisplayVersion, Publisher, InstallDate |Format-Table -AutoSize

Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* |  Select-Object DisplayName, DisplayVersion, Publisher, InstallDate |
Where-Object {($_.displayname -like "*Engagement*")  } |`
 Format-Table –AutoSize 

1 Answer 1

2

I went with a RegEx approach to condensing your Where-Object filtering to a single instance, but you could also use -OR to also bring it into a single instance. Also, there is no need to do a Select-Object into a Format-Table as just using Format-Table will let you specify what properties to display.

Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object {
    $_.DisplayName -match '^Database Engine Services|Engagement'
} | Format-Table DisplayName, DisplayVersion, Publisher, InstallDate -AutoSize

Here is the alternative using -OR with your -LIKE statement:

Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object {
    $_.DisplayName -LIKE 'Database Engine Services*' -OR $_.DisplayName -LIKE '*Engagement*'
} | Format-Table DisplayName, DisplayVersion, Publisher, InstallDate -AutoSize
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you Sir @boeprox. I am big fan of you and your Get-SQLInstance and I used to automate my project stuff. Yes this fixed my issue. Thank you sir.

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.