Last active
October 31, 2018 09:00
-
-
Save markhallen/f4b74e5cac5b769068d5105854853438 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-ArpPropertyByDisplayName { | |
<# | |
.SYNOPSIS | |
Get an application property from Programs and Features | |
.DESCRIPTION | |
Will accept a DisplayName value that will be searched for in Programs and Features and will | |
return the property. | |
.PARAMETER DisplayName | |
The DisplayName as it found in Programs and Features | |
.NOTES | |
Author: Mark Allen | |
Created: 16/08/2018 | |
.LINK | |
http://www.markallenit.com/blog/ | |
.EXAMPLE | |
Get-ArpPropertyByDisplayName -DisplayName 'Google Chrome' | |
Will find any entry in Programs and Features named 'Google Chrome and will return the | |
UninstallString. | |
.EXAMPLE | |
Get-ArpPropertyByDisplayName -DisplayName 'Google Chrome' -Property QuietUninstallString | |
Will find any entry in Programs and Features named 'Google Chrome and will return the | |
QuietUninstallString. | |
#> | |
param ( | |
[parameter( | |
Mandatory=$true, | |
Position = 0 | |
)] | |
[ValidateNotNullOrEmpty()] | |
[string] | |
$DisplayName, | |
[parameter( | |
Mandatory=$false | |
)] | |
[ValidateNotNullOrEmpty()] | |
[string] | |
$Property = 'UninstallString' | |
) | |
Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall | | |
Get-ItemProperty | | |
Where-Object {$_.DisplayName -eq $DisplayName } | | |
Select-Object -ExpandProperty $Property | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment