Finding All Cmdlets Associated with a Particular PSSnapIn

With the release of the PowerShell Community Extensions I have been wanting to provide automatic ways to disover the functionality that comes with it.  Let’s face it, documentation tends to be static and often isn’t up-to-date and/or correct.  So I added an alias for the 1.0 alias that will list all of the PSCX created aliases:

galpscx

This works only because we have adopted a convention of using the "Description" property of Set-Alias and we start each description with "PSCX". So all the galpscx aliases does is expand to a Get-AliasPscx function which does this:

Get-Alias | ?{$_.Description -match "^PSCX"}

It turns out that each cmdlets indicates which PSSnapIn it is associated with which is way cool e.g.:

22> gcm Set-FileTime | fl *

DLL              : C:\Program Files\PowerShell Community Extensions\Pscx.dll
Verb             : Set
Noun             : FileTime
HelpFile         : Pscx.dll-Help.xml
PSSnapIn         : Pscx

<snip>

Note that you have to specify "fl *" to get the PSSnapIn property to display.  Now you can do something like this:

15> gcm -type cmdlet | group PSSnapin | fl *

Values : {Microsoft.PowerShell.Management}
Count  : 47
Group  : {Add-Content, Clear-Content, Clear-Item, Clear-ItemProperty, Convert-P
         ath, Copy-Item, Copy-ItemProperty, Get-ChildItem, Get-Content, Get-Eve
         ntLog, Get-Item, Get-ItemProperty, Get-Location, Get-Process, Get-PSDr
         ive, Get-PSProvider, Get-Service, Get-WmiObject, Invoke-Item, Join-Pat
         h, Move-Item, Move-ItemProperty, New-Item, New-ItemProperty, New-PSDri
         ve, New-Service, Pop-Location, Push-Location, Remove-Item, Remove-Item
         Property, Remove-PSDrive, Rename-Item, Rename-ItemProperty, Resolve-Pa
         th, Restart-Service, Resume-Service, Set-Content, Set-Item, Set-ItemPr
         operty, Set-Location, Set-Service, Split-Path, Start-Service, Stop-Pro
         cess, Stop-Service, Suspend-Service, Test-Path}
Name   : Microsoft.PowerShell.Management

<snip>

or to see what is in a particular pssnapin:

23> gcm -type cmdlet | ? {$_.PSSnapin -match "^Pscx"}

CommandType     Name                            Definition
———–     —-                            ———-
Cmdlet          ConvertFrom-Base64              ConvertFrom-Base64 [-Base64T…
Cmdlet          ConvertTo-Base64                ConvertTo-Base64 [-Bytes] <B…
Cmdlet          ConvertTo-MacOs9LineEnding      ConvertTo-MacOs9LineEnding […
Cmdlet          ConvertTo-UnixLineEnding        ConvertTo-UnixLineEnding [-P…
Cmdlet          ConvertTo-WindowsLineEnding     ConvertTo-WindowsLineEnding …
Cmdlet          Convert-Xml                     Convert-Xml [-Path] <String[…
Cmdlet          Format-Hex                      Format-Hex [-Path] <String[]…
Cmdlet          Format-Xml                      Format-Xml [-Path] <String[]…
Cmdlet          Get-Clipboard                   Get-Clipboard [-Verbose] [-D…
Cmdlet          Get-CmdletMaml                  Get-CmdletMaml [-Path] <Stri…
Cmdlet          Get-ForegroundWindow            Get-ForegroundWindow [-Verbo…
Cmdlet          Get-Hash                        Get-Hash [-Path] <String[]> …
Cmdlet          Get-MountPoint                  Get-MountPoint [[-Root] <Str…
Cmdlet          Get-Privilege                   Get-Privilege [[-Identity] <…
Cmdlet          Get-ShortPath                   Get-ShortPath [-Path] <Strin…
Cmdlet          Join-String                     Join-String [-Strings] <Stri…
Cmdlet          New-HardLink                    New-HardLink [[-FilePath] <S…
Cmdlet          Out-Clipboard                   Out-Clipboard [-InputObject]…
Cmdlet          Remove-MountPoint               Remove-MountPoint [[-Name] <…
Cmdlet          Send-SmtpMail                   Send-SmtpMail [-SmtpHost <St…
Cmdlet          Set-FileTime                    Set-FileTime [-Path] <String…
Cmdlet          Set-ForegroundWindow            Set-ForegroundWindow [[-Hand…
Cmdlet          Set-VolumeLabel                 Set-VolumeLabel [[-Path] <St…
Cmdlet          Split-String                    Split-String [[-Separator] <…
Cmdlet          Start-Process                   Start-Process [[-Path] <Stri…
Cmdlet          Stop-RemoteDesktop              Stop-RemoteDesktop [-Id] <In…
Cmdlet          Test-Xml                        Test-Xml [-Path] <String[]> …
Cmdlet          Write-Clipboard                 Write-Clipboard [-Object] <P…

For the next version of PSCX I’ll be adding a function Get-PSSnapInCmdlet that will take a search pattern for specifying the PSSnapIn as well as an alias gcmpscx that lists all the PSCX provided cmdlets.

Advertisements
This entry was posted in PowerShell. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s