-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGet-FileTypePersistentHandler.ps1
More file actions
67 lines (61 loc) · 2.45 KB
/
Copy pathGet-FileTypePersistentHandler.ps1
File metadata and controls
67 lines (61 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# .SYNOPSIS
# Queries all file types with associated filter handlers and lists their respective filter handlers.
# .DESCRIPTION
# Queries all file types with associated filter handlers and lists their respective filter handlers.
# .OUTPUTS
# List of PSObject.
[CmdletBinding()]
[OutputType([System.Collections.Generic.List[PSObject]])]
param()
$Records = [System.Collections.Generic.List[PSObject]]::new()
try {
$ClassesKey = [Microsoft.Win32.Registry]::LocalMachine.OpenSubKey('Software\Classes', $False)
$Extensions = $ClassesKey.GetSubKeyNames()
foreach ($extension in $Extensions) {
if (-not $extension.StartsWith('.')) { continue }
Write-Verbose "Extension $extension"
try {
$extensionKey = $ClassesKey.OpenSubKey($extension, $False)
if ($Null -eq $extensionKey) { continue }
$progId = $extensionKey.GetValue('')
try {
$phKey = $extensionKey.OpenSubKey('PersistentHandler', $False)
if ($Null -ne $phKey) {
$Records.Add([PSCustomObject]@{
Extension = $extension
ProgID = $Null
ProgIDCLSID = $Null
DefaultPersistentHandler = $phKey.GetValue('')
OriginalPersistentHandler = $phKey.GetValue('OriginalPersistentHandler')
})
}
}
finally { if ($Null -ne $phKey) { $phKey.Close() } }
}
finally { if ($Null -ne $extensionKey) { $extensionKey.Close() } }
if (-not [string]::IsNullOrWhiteSpace($progId)) {
try {
$progIdClsidKey = $ClassesKey.OpenSubKey("$progId\CLSID", $False)
if ($Null -ne $progIdClsidKey) {
$clsid = $progIdClsidKey.GetValue('')
try {
$phKey = $ClassesKey.OpenSubKey("CLSID\$clsid\PersistentHandler", $False)
if ($Null -ne $phKey) {
$Records.Add([PSCustomObject]@{
Extension = $extension
ProgID = $progId
ProgIDCLSID = $clsid
DefaultPersistentHandler = $phKey.GetValue('')
OriginalPersistentHandler = $phKey.GetValue('OriginalPersistentHandler')
})
}
}
finally { if ($Null -ne $phKey) { $phKey.Close() } }
}
}
finally { if ($Null -ne $progIdClsidKey) { $progIdClsidKey.Close() } }
}
}
}
finally { if ($Null -ne $ClassesKey) { $ClassesKey.Close() } }
return $Records