Created
March 18, 2016 15:58
-
-
Save trstringer/bcbc3c500382eb303501 to your computer and use it in GitHub Desktop.
Retrieve all URI associations for apps from the registry
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
if (!(Test-Path "hkcr:\")) { | |
New-PSDrive -PSProvider registry -Root HKEY_CLASSES_ROOT -Name HKCR -ErrorAction Stop | Out-Null | |
} | |
$rootKey = "HKCR:\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppModel\Repository\Packages" | |
$associationsParent = "App\Capabilities\URLAssociations" | |
$output = | |
foreach ($child in (Get-ChildItem -Path $rootKey)) { | |
try { | |
$reg = Get-Item "$($child.Name.Replace("HKEY_CLASSES_ROOT", "HKCR:"))\$associationsParent" -ErrorAction Stop | |
$packageDisplayName = Get-ItemProperty -Path "$($child.Name.Replace("HKEY_CLASSES_ROOT", "HKCR:"))" -Name "DisplayName" -ErrorAction Stop | Select-Object -ExpandProperty DisplayName | |
Get-ItemProperty $reg.Name.Replace("HKEY_CLASSES_ROOT", "HKCR:") | | |
Get-Member -ErrorAction Stop | | |
Select-Object -ExpandProperty Name | | |
Where-Object {$_ -notin "Equals", "GetHashCode", "GetType", "ToString", "PSChildName", "PSDrive", "PSParentPath", "PSPath", "PSProvider"} | | |
Select-Object @{Name = "Package"; Expression = { $child.Name.Substring($child.Name.LastIndexOf("\") + 1, $child.Name.Length - $child.Name.LastIndexOf("\") - 1) }}, | |
@{Name = "DisplayName"; Expression = { $packageDisplayName }}, | |
@{Name = "Uri"; Expression = { $_ }} | |
} | |
catch { | |
# silence the error | |
$reg = $null | |
$packageDisplayName = "" | |
} | |
} | |
$output | Format-List |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment