Skip to content

Instantly share code, notes, and snippets.

@aetos382
Last active November 16, 2020 23:38
Show Gist options
  • Select an option

  • Save aetos382/5da9fee760b3ca35581e85dae656481e to your computer and use it in GitHub Desktop.

Select an option

Save aetos382/5da9fee760b3ca35581e85dae656481e to your computer and use it in GitHub Desktop.
$keys =
Get-ChildItem -LiteralPath 'Registry::HKEY_CLASSES_ROOT' |
Add-Member -MemberType ScriptProperty -Name 'LeafName' -Value { Split-Path -Leaf $this.PSPath } -Force -PassThru |
? { $_.LeafName.StartsWith('.') } |
% {
$progIds = @($_.GetValue(''))
$key = Get-Item -LiteralPath (Join-Path -Path $_.PSPath -ChildPath 'OpenWithProgIds') -ErrorAction Ignore
if ($key) {
$progIds += @($key.GetValueNames())
}
foreach ($progId in $progIds) {
$progIdKey = Get-Item -LiteralPath "Registry::HKEY_CLASSES_ROOT\${progId}" -ErrorAction Ignore
if ($progIdKey) {
$description = $progIdKey.GetValue('')
if ($description) {
$_ | Add-Member -MemberType NoteProperty -Name 'Description' -Value $description -Force
break
}
}
}
$_
}
$extensions = $keys |
Sort-Object -Property @{ Expression = { $_.LeafName.Length }; Descending = $true } |
Select-Object -First 100 -Property 'LeafName', 'Description'
$extensions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment