Skip to content

Instantly share code, notes, and snippets.

@MHaggis
Created November 15, 2024 19:29
Show Gist options
  • Save MHaggis/a5b0af617ae62ded5a2ec4f15a96f4ac to your computer and use it in GitHub Desktop.
Save MHaggis/a5b0af617ae62ded5a2ec4f15a96f4ac to your computer and use it in GitHub Desktop.
$associations = @()
$registryPaths = @(
"HKLM:\Software\Classes",
"HKCU:\Software\Classes"
)
foreach ($path in $registryPaths) {
Get-ChildItem $path | ForEach-Object {
if ($_.PSChildName -like ".*") {
$extension = $_.PSChildName
$progId = (Get-ItemProperty -Path "$($_.PSPath)" -ErrorAction SilentlyContinue).'(Default)'
if ($progId) {
$commandPath = (Get-ItemProperty -Path "$path\$progId\shell\open\command" -ErrorAction SilentlyContinue).'(Default)'
$associations += [PSCustomObject]@{
Extension = $extension
ProgID = $progId
AssociatedApp = $commandPath
}
}
}
}
}
$associations | Out-GridView -Title "File Extensions and Associated Applications"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment