#PSTip Explore all possible -Verb values for registered file extensions

In previous tips we saw how to find possible values of -Verb parameter and how to use it. What about to check all possible -Verb values for all extensions?

First, let’s investigate all registered (associated) extensions in the system. There is a native tool named assoc. As it’s a part of cmd.exe, we have to call it inside command line. If it’s used without a parameter, it will display all associations.

PS> cmd /c assoc | Select-Object -First 10
.323=h323file
.386=vxdfile
.3g2=VLC.3g2
.3gp=VLC.3gp
.3gp2=VLC.3gp2
.3gpp=VLC.3gpp
.5vw=wireshark-capture-file
.7Z=WinZip
.aac=aacfile
.aca=Agent.Character.2

Let’s test the whole process with the first extension returned. We need to split input line to receive just that extension.

PS> cmd /c assoc | Select-Object -First 1 | ForEach { ($_ -split '=')[0] }
.323

We used Split operator to obtain just the text before the equal sign. Now we’ll use previous tip to see all possible -Verb values.

cmd /c assoc |
Select-Object -First 1 |
ForEach { ($_ -split '=')[0] } |
ForEach { (New-Object System.Diagnostics.ProcessStartInfo -ArgumentList "test$_").Verbs }
open

We created a new ProcessStartInfo object and passed a dummy file name to it – in this case named test.323. From the object we created, we extracted only its Verbs property. As we don’t need to create an object from the output, it’s sufficient to send the output to Out-GridView cmdlet. But before that, let’s remove double call of ForEach-Object cmdlet.

cmd /c assoc |
Select-Object -First 10 |
ForEach { $ext = ($_ -split '=')[0]; "{0}: {1}" -f $ext, ((New-Object System.Diagnostics.ProcessStartInfo -ArgumentList "test$ext").Verbs -join ', ') }

.323: open
.386:
.3g2: AddToPlaylistVLC, Open, PlayWithVLC
.3gp: AddToPlaylistVLC, Open, PlayWithVLC
.3gp2: AddToPlaylistVLC, Open, PlayWithVLC
.3gpp: AddToPlaylistVLC, Open, PlayWithVLC
.5vw: open
.7Z: open, print
.aac: Batch Convert with WavePad Sound Editor, Convert sound file, Edit sound file, Edit with WavePad Sound Editor
.aca:

We used PowerShell’s format operator (-f) to have output formatted like: ext: Verb1, Verb2, … Now we can remove Select-Object and send all data to the Out-GridView:

cmd /c assoc |
ForEach { $ext = ($_ -split '=')[0]; "{0}: {1}" -f $ext, ((New-Object System.Diagnostics.ProcessStartInfo -ArgumentList "test$ext").Verbs -join ', ') } | Out-GridView -Title 'Verb values for associated extensions'

Share on: