Last active
September 2, 2026 15:49
-
-
Save ericlaw1979/f4a8ecf4b14e05765487799cf0241c58 to your computer and use it in GitHub Desktop.
Enumerates Windows file extensions that register for a Preview or Thumbnail handler
This file contains hidden or 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
| $hkcrPath = "Registry::HKEY_CLASSES_ROOT" | |
| $previewClsid = "{8895b1c6-b41f-4c1c-a562-0d564250836f}" | |
| $thumbnailClsid = "{E357FCCD-A995-4576-B01F-234630154E96}" | |
| Write-Host "--------------------------------------------------" | |
| Write-Host "Enumerating file type extensions that register" -ForegroundColor Cyan | |
| Write-Host "preview or thumbnail handlers..." -ForegroundColor Cyan | |
| Write-Host "--------------------------------------------------" | |
| $extensions = Get-ChildItem -Path $hkcrPath | Where-Object { $_.PSChildName -like ".*" } | |
| foreach ($ext in $extensions) { | |
| $extName = $ext.PSChildName | |
| # 1. Attempt to get the ProgID from the extension's (default) value | |
| $progId = (Get-ItemProperty -Path "$hkcrPath\$extName" -Name "(default)" -ErrorAction SilentlyContinue)."(default)" | |
| $previewGuid = $null | |
| $thumbnailGuid = $null | |
| $previewSource = $null | |
| $thumbnailSource = $null | |
| # 2. Check direct Extension paths first (these usually override ProgIDs) | |
| $extPreviewPath = "$hkcrPath\$extName\ShellEx\$previewClsid" | |
| $extThumbnailPath = "$hkcrPath\$extName\ShellEx\$thumbnailClsid" | |
| if (Test-Path -Path $extPreviewPath -ErrorAction SilentlyContinue) { | |
| $previewGuid = (Get-ItemProperty -Path $extPreviewPath -Name "(default)" -ErrorAction SilentlyContinue)."(default)" | |
| $previewSource = "Registered for '$extName' directly" | |
| } | |
| if (Test-Path -Path $extThumbnailPath -ErrorAction SilentlyContinue) { | |
| $thumbnailGuid = (Get-ItemProperty -Path $extThumbnailPath -Name "(default)" -ErrorAction SilentlyContinue)."(default)" | |
| $thumbnailSource = "Registered for '$extName' directly" | |
| } | |
| # 3. If missing from Extension, check the ProgID (if one exists) | |
| if ($progId -and ($progId -is [string]) -and ($progId.Trim() -ne "")) { | |
| $progPreviewPath = "$hkcrPath\$progId\ShellEx\$previewClsid" | |
| $progThumbnailPath = "$hkcrPath\$progId\ShellEx\$thumbnailClsid" | |
| if (-not $previewGuid -and (Test-Path -Path $progPreviewPath -ErrorAction SilentlyContinue)) { | |
| $previewGuid = (Get-ItemProperty -Path $progPreviewPath -Name "(default)" -ErrorAction SilentlyContinue)."(default)" | |
| $previewSource = "Registered for ProgID '$progId'" | |
| } | |
| if (-not $thumbnailGuid -and (Test-Path -Path $progThumbnailPath -ErrorAction SilentlyContinue)) { | |
| $thumbnailGuid = (Get-ItemProperty -Path $progThumbnailPath -Name "(default)" -ErrorAction SilentlyContinue)."(default)" | |
| $thumbnailSource = "Registered for ProgID '$progId'" | |
| } | |
| } | |
| # 4. Output if either handler was found in either location | |
| if ($previewGuid -or $thumbnailGuid) { | |
| [PSCustomObject]@{ | |
| Extension = $extName | |
| ProgID = $progId | |
| PreviewHandlerGUID = $previewGuid | |
| PreviewSource = $previewSource | |
| ThumbnailHandlerGUID = $thumbnailGuid | |
| ThumbnailSource = $thumbnailSource | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment