Using the Show-Command cmdlet in PowerShell 3.0

Hi All,

A useful cmdlet that was introduced in PowerShell 3.0 is the show-command. This can be used for quickly generating a command in PowerShell and is a great learning tool.

First thing you can do to get started is simply open PowerShell and type “show-command” and press enter. You will see a GUI interface opens up with a list of cmdlets and an option to choose from different modules as shown below.

In this example I will be choosing the “Send-MailMessage” to demonstrate the usefulness of the “Show-Command” cmdlet. Type in “Send” in the “Name” box and choose the “Send-MailMessage” cmdlet and you will see a list of parameters show up as shown below.

Fill in the parameters as necessary to complete your command as shown in the next illustration.

When you are finished filling in all the information you need you can either click the “Run” or you can click “copy”. If you click the “Run” button it will copy the command to the PowerShell window and immediately run it as shown below. In this example the code would execute and an email message that would be sent from BC@pipe2text.com to JA@pipe2text.com with a subject of “Show-Command is really cool” and a body stating “This is a good learning tool!” The message would be sent using the SMTP server smtp.pipe2text.com.

If you click “copy’ you can then paste the code somewhere else for review it, manipulate it or to add to a script etc…

As you can see from the example above, this really can be used as an excellent learning tool or a way to put together a quick PowerShell command. The above is just one example of using the “Show-Command” cmdlet to create commands for another cmdlet. Depending on the cmdlet you choose the options will differ.

I hope this helps and have fun! As always, if you have any questions or feedback, please a comment.

Related Links:

Getting Started With PowerShell 2.0

Recording the Commands and Output of a PowerShell Session to a text file in PowerShell 2.0

Using the Server Manager Module in PowerShell to Install Roles and Features On a Windows Server

Share Button
Author: BC

BC is a Pipe2text.com contributor and has been an IT Professional for 15 years. He currently works as a Sr. Systems Engineer at a private firm. He enjoys working with Active Directory, Exchange and VMware among other technologies.


Leave a Reply

Your email address will not be published. Required fields are marked *