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.