Automating the world one-liner at a time…
If you know the basics of get-command, feel free to skip this section.
If you are searching for a cmdlet to add a printer, you could star with something like:
PS C:\Users\mspuser> get-command *printer*
CommandType Name ModuleName
----------- ---- ----------
Function Add-Printer PrintManagement
Function Add-PrinterDriver PrintManagement
Function Add-PrinterPort PrintManagement
Function Get-Printer PrintManagement
Function Get-PrinterDriver PrintManagement
Function Get-PrinterPort PrintManagement
Function Get-PrinterProperty PrintManagement
Function Remove-Printer PrintManagement
Function Remove-PrinterDriver PrintManagement
Function Remove-PrinterPort PrintManagement
Function Rename-Printer PrintManagement
Function Set-Printer PrintManagement
Function Set-PrinterProperty PrintManagement
Cmdlet Out-Printer Microsoft.PowerShell.Utility
Notice the choice of the noun “printer”, as opposed to the verb “add”. “Add” could be adding anything, so reducing the scope to “printer” allows for a more precise initial search.
For this simple case of adding a printer, it is very possible that the first guess would be “add-printer”, but the verb is not always as simple to guess. Also, it is nice to look around and see what other printer related cmdlets are available. Chances are one task leads to another and we will need another cmdlet soon like get-printer to see that the printer we added is there.
The first * in *printer* allows finding cmdlets with any verb or noun prefix. By “noun prefix” I mean the cmdlet developers could have called them SystemPrinters, PSPrinters, or other name. The second * allows for any noun suffix like “Driver” and “Property” in the list above.
After looking at the list, we might conclude that we are not interested in “PrinterDriver” or “PrinterPort” so that the second * made our search less precise. We can issue the command again without the second * for less results but, for the generic case of searching for any other noun, using both * will guarantee we will not miss anything.
After you found the cmdlet, you can explorer it a bit further with one of the following:
get-help add-printer
get-command add-printer
We saw in Running show-command for a cmdlet, how to use show-command for a specific cmdlet. If you run just “show-command” this is what you get:
Note:
If then you type “printer” under Name, you have:
Notice that *printer* is implicit. If the cmdlet contains printer, you will see it.
If you had typed printers, you would see the same list, because the search results also include the singular form of what you typed.
When you click the Add-Printer cmdlet you get the window on the left below, and after you click “Show-Details” you get the window on the right:
Show-command allows for a simpler way to find a cmdlet and then to get more details about it such as parameters and help (question mark button). It is a simpler route from thinking about a task to finding out how to accomplish it.
Notes:
Lucio Silveira [MSFT]
Should this be show-command in the 'section heading' thingy?
***
Finding cmdlets with show-cmdlet