-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathGet-Ftype.ps1
73 lines (65 loc) · 3.28 KB
/
Get-Ftype.ps1
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
68
69
70
71
72
73
function Get-Ftype {
<#
.SYNOPSIS
Displays file types used in file extension associations
.DESCRIPTION
Displays file types used in file extension associations which can only gotten from cmd.exe
.PARAMETER AsArray
Switch to return result as an array of objects as opposed to an ordered dictionary
.EXAMPLE
Get-Ftype
Name Value
---- -----
VLC.rec "C:\Program Files\VideoLAN\VLC\vlc.exe" --started-from-file "%1"
ChromeHTML "C:\Program Files\Google\Chrome\Application\chrome.exe" --single-argument %1
... snip many lines ...
VLC.rmvb "C:\Program Files\VideoLAN\VLC\vlc.exe" --started-from-file "%1"
.EXAMPLE
Get-Ftype -AsArray | Where-Object { $_.Name -match '^Word' }
Name Value
---- -----
Word.AutoRecovery.8 "C:\Program Files (x86)\Microsoft Office\Root\Office16\WINWORD.EXE" /n "%1" /o "%u"
Word.Backup.8 "C:\Program Files (x86)\Microsoft Office\Root\Office16\WINWORD.EXE" /n "%1" /o "%u"
Word.Document.12 "C:\Program Files (x86)\Microsoft Office\Root\Office16\WINWORD.EXE" /n "%1" /o "%u"
Word.Document.8 "C:\Program Files (x86)\Microsoft Office\Root\Office16\WINWORD.EXE" /n "%1" /o "%u"
Word.DocumentMacroEnabled.12 "C:\Program Files (x86)\Microsoft Office\Root\Office16\WINWORD.EXE" /n "%1" /o "%u"
Word.OpenDocumentText.12 "C:\Program Files (x86)\Microsoft Office\Root\Office16\WINWORD.EXE" /n "%1"
Word.RTF.8 "C:\Program Files (x86)\Microsoft Office\Root\Office16\WINWORD.EXE" /n "%1" /o "%u"
Word.Template.12 "C:\Program Files (x86)\Microsoft Office\Root\Office16\WINWORD.EXE" /n "%1" /o "%u"
Word.Template.8 "C:\Program Files (x86)\Microsoft Office\Root\Office16\WINWORD.EXE" /n "%1" /o "%u"
Word.TemplateMacroEnabled.12 "C:\Program Files (x86)\Microsoft Office\Root\Office16\WINWORD.EXE" /n "%1" /o "%u"
Word.UriLink.16 C:\Program Files (x86)\Microsoft Office\Root\Office16\protocolhandler.exe "%1"
wordhtmlfile "C:\Program Files (x86)\Microsoft Office\Root\Office16\WINWORD.EXE"
wordhtmltemplate "C:\Program Files (x86)\Microsoft Office\Root\Office16\WINWORD.EXE"
Wordpad.Document.1 "%ProgramFiles%\Windows NT\Accessories\WORDPAD.EXE" "%1"
#>
[CmdletBinding()]
param (
[switch] $AsArray
)
begin {
Write-Verbose -Message "Starting [$($MyInvocation.Mycommand)]"
}
process {
$CmdReturn = (cmd.exe /d /c ftype)
$GetFtype = ([ordered] @{})
ForEach ($CurItem in $CmdReturn) {
$Temp = $CurItem.Split('=')
$GetFtype.Add($Temp[0],$Temp[1])
}
if ($AsArray) {
$ArrayOutput = $GetFtype.GetEnumerator() | ForEach-Object {
new-object -TypeName psobject -Property ([ordered] @{
FType = $_.Name
Program = $_.Value
})
}
Write-Output -InputObject $ArrayOutput
} else {
Write-Output -InputObject $GetFtype
}
}
end {
Write-Verbose -Message "Ending [$($MyInvocation.Mycommand)]"
}
}