Skip to content
Menu
The Lonely Administrator
  • PowerShell Tips & Tricks
  • Books & Training
  • Essential PowerShell Learning Resources
  • Privacy Policy
  • About Me
The Lonely Administrator

Browsing PowerShell Commands

Posted on June 25, 2013

Whenever I'm exploring a new PowerShell module or snapin, one of the first things I do is list all of the commands found within the module.

Manage and Report Active Directory, Exchange and Microsoft 365 with
ManageEngine ADManager Plus - Download Free Trial

Exclusive offer on ADManager Plus for US and UK regions. Claim now!
PS C:\scripts> get-command -module psworkflow

CommandType     Name                                               ModuleName
-----------     ----                                               ----------
Function        New-PSWorkflowSession                              PSWorkflow
Cmdlet          New-PSWorkflowExecutionOption                      PSWorkflow

You can specify either a module or a snapin. Use the -module parameter for both. However, for larger modules, I've realized I need a better way to browse the commands. For example, I might need to see them organized by verb or noun. That information is included with the Get-Command expression. I simply have to ask for it. Here's a more thorough command and the result.

get-command -mod Hyper-V | select Name,Noun,Verb,CommandType

get-command-mod

I included the command type because some modules might contains cmdlets and functions. I could revise this expression and insert a sort command. But that's too much typing. Especially if I want to sort and re-sort. Instead, I'll pipe this command to Out-Gridview.

get-command -mod Hyper-V | select Name,Noun,Verb,CommandType | Out-Gridview -Title "Hyper-V"

get-command-mod-ogv

Now I have a sortable and filterable view of all the commands. Plus, it is in a separate window so I have my prompt back and get help for listed commands. I even decided to build a quick-and-dirty function.

Function Get-CommandGridView {

[cmdletbinding()]

Param([string]$Name)

 #get commands for the module or snapin
 $commands = Get-Command -Module $name

 #if module or snapin not found, Get-Command doesn't throw an exception
 #so I'll simply test if $commands contains anything
 if ($commands) {
    #include the module name because $Name could contain a wildcard
    $Commands | 
    Select-Object -Property Name,Noun,Verb,CommandType,ModuleName | 
    Out-Gridview -Title "$($Name.ToUpper()) Commands"
 }
 else {
    Write-Warning "Failed to find any commands for module or snapin $name"
 }

} #close Get-CommandGridView

Set-Alias -Name gcgv -Value Get-CommandGridView

Because the module or snapin name can include a wildcard, I added the module name to the output. Now I have a tool to grab all the commands from a module or set of modules and I can filter and browse all I want without having to retype or revise commands at the prompt.


Behind the PowerShell Pipeline

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Mastodon (Opens in new window) Mastodon
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to print (Opens in new window) Print
  • Click to email a link to a friend (Opens in new window) Email

Like this:

Like Loading...

Related

3 thoughts on “Browsing PowerShell Commands”

  1. Pingback: Microsoft Most Valuable Professional (MVP) – Best Posts of the Week around Windows Server, Exchange, SystemCenter and more – #35 - TechCenter - Blog - TechCenter – Dell Community
  2. Pingback: Microsoft Most Valuable Professional (MVP) – Best Posts of the Week around Windows Server, Exchange, SystemCenter and more – #35 - Dell TechCenter - TechCenter - Dell Community
  3. Pingback: Browsing PowerShell Commands using a grid window - Jan Egil`s blog on Microsoft Infrastructure

Comments are closed.

reports

Powered by Buttondown.

Join me on Mastodon

The PowerShell Practice Primer
Learn PowerShell in a Month of Lunches Fourth edition


Get More PowerShell Books

Other Online Content

github



PluralSightAuthor

Active Directory ADSI Automation Backup Books CIM CLI conferences console Friday Fun FridayFun Function functions Get-WMIObject GitHub hashtable HTML Hyper-V Iron Scripter ISE Measure-Object module modules MrRoboto new-object objects Out-Gridview Pipeline PowerShell PowerShell ISE Profile prompt Registry Regular Expressions remoting SAPIEN ScriptBlock Scripting Techmentor Training VBScript WMI WPF Write-Host xml

©2025 The Lonely Administrator | Powered by SuperbThemes!
%d