Often the command line can seem like an unfamiliar and daunting area of the operating system, which new users are reluctant to investigate. The lack of a user interface which can be clicked on often outweighs the benefits that short, quick commands can offer. In PowerShell 3.0, Microsoft has added a simple cmdlet to aid in eliminating this stumbling block. This cmdlet is Show-Command
.
Running Show-Command
without any parameters opens a user interface with a drop-down list of available modules and a list box full of all the cmdlet, aliases, drives, and functions available in those modules. The commands in the list will depend on what is installed on the machine and the list will differ per machine. This is done as follows:
PS C:\> Show-Command
There is a textbox for searching the list available under the Modules drop-down list. If you select one of the commands, drives, or functions, a new pane will open at the bottom of the window, as shown in the following screenshot, which shows all the parameters for the cmdlet and allows you to run, copy, or view the help for a particular item:
You can pass the name of a cmdlet to the Show-Command
cmdlet through the Name parameter as well. In this mode, the Show-Command
user interface allows for input into the named cmdlet. All the parameters and parameter sets are available for the user to select from and provide input. For this, you can enter the following command:
PS C:\> Show-Command -Name Get-Process
By clicking on the Copy button, a string of text is copied to the clipboard, which is the result of the data entered into the user interface. This text could then be pasted into a script editor or the command line for execution. When clicking on the Run button, the command is executed and the output is not displayed in the user interface, but rather written to the console. Additionally, the size of the resulting window can be adjusted using the Height
and Width
parameters of the cmdlet.
Another interesting feature of the Show-Command
cmdlet is the ? button (shown in the previous screenshot). This button is only available when the Name
parameter is specified or a cmdlet is selected from the first view shown previously. Clicking on the button will open a new window with the help for the current command. This is explained by the following command:
PS C:\> Show-Command New-Item
The output is shown in the following screenshot:
Note
Note that the cmdlet Show-Command
is blocking the view and you will not be able to interact with the PowerShell console while the window is open.
The Show-Command
is an interesting cmdlet to add to an until-now-command line-only shell. The benefit is that it offers a simple visual view of many cmdlets and the respective help. This can help users overcome the shell-shock, which is often associated with opening PowerShell for the first time. Additionally, the cmdlets can be of value to administrators looking to shortcut some of the unnecessary typing that must be done for the cmdlets with lots of parameters. Rather than having to type them out, you can now find yourself tabbing through the Show-Command
user interface.