{"id":2311,"date":"2012-06-20T19:49:28","date_gmt":"2012-06-20T19:49:28","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/powershell\/2012\/06\/20\/running-show-command-to-discover-cmdlets\/"},"modified":"2024-02-26T14:21:25","modified_gmt":"2024-02-26T22:21:25","slug":"running-show-command-to-discover-cmdlets","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/running-show-command-to-discover-cmdlets\/","title":{"rendered":"Running show-command to discover cmdlets"},"content":{"rendered":"<h2><span style=\"font-size: large;\"><span style=\"color: #4f81bd;\"><span style=\"font-family: Cambria;\"><span style=\"font-size: large;\"><span style=\"color: #4f81bd;\"><span style=\"font-family: Cambria;\"><em><span style=\"color: #a5a5a5;\">This blog post applies to the Windows PowerShell\u00a0Version 3.0.\u00a0<\/span><\/em><\/span><\/span><\/span><\/span><\/span><\/span><\/h2>\n<h2><span style=\"font-size: large;\"><span style=\"color: #4f81bd;\"><span style=\"font-family: Cambria;\">Problem: How can I find out what cmdlets are available for a given task?\u00a0<\/span><\/span><\/span><\/h2>\n<h2><span style=\"font-size: large;\"><span style=\"color: #4f81bd;\"><span style=\"font-family: Cambria;\">Finding cmdlets in the traditional way<\/span><\/span><\/span><\/h2>\n<p><strong><span style=\"font-size: medium;\"><span style=\"font-family: Calibri;\">\u00a0<\/span><span style=\"font-family: Calibri;\">If you know the basics of get-command, feel free to skip this section.<\/span><\/span><\/strong><\/p>\n<p><span style=\"font-size: medium;\"><span style=\"font-family: Calibri;\">If you are searching for a cmdlet to add a printer, you could star with something like:<\/span><\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-family: courier new,courier;\">PS C:\\Users\\mspuser&gt; get-command *printer*<\/span><\/p>\n<p><span style=\"font-family: courier new,courier; font-size: small;\">CommandType\u00a0\u00a0\u00a0 Name\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ModuleName<\/span><\/p>\n<p><span style=\"font-family: courier new,courier; font-size: small;\">&#8212;&#8212;&#8212;&#8211;\u00a0\u00a0\u00a0 &#8212;-\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &#8212;&#8212;&#8212;-<\/span><\/p>\n<p><span style=\"font-family: courier new,courier; font-size: small;\">Function\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Add-Printer\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 PrintManagement<\/span><\/p>\n<p><span style=\"font-family: courier new,courier; font-size: small;\">Function\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Add-PrinterDriver\u00a0\u00a0\u00a0\u00a0\u00a0 PrintManagement<\/span><\/p>\n<p><span style=\"font-family: courier new,courier; font-size: small;\">Function\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Add-PrinterPort\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 PrintManagement<\/span><\/p>\n<p><span style=\"font-family: courier new,courier; font-size: small;\">Function\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Get-Printer\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 PrintManagement<\/span><\/p>\n<p><span style=\"font-family: courier new,courier; font-size: small;\">Function\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Get-PrinterDriver\u00a0\u00a0\u00a0\u00a0\u00a0 PrintManagement<\/span><\/p>\n<p><span style=\"font-family: courier new,courier; font-size: small;\">Function\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0Get-PrinterPort\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 PrintManagement<\/span><\/p>\n<p><span style=\"font-family: courier new,courier; font-size: small;\">Function\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Get-PrinterProperty\u00a0\u00a0\u00a0 PrintManagement<\/span><\/p>\n<p><span style=\"font-family: courier new,courier; font-size: small;\">Function\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Remove-Printer\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 PrintManagement<\/span><\/p>\n<p><span style=\"font-family: courier new,courier; font-size: small;\">Function\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Remove-PrinterDriver\u00a0\u00a0 PrintManagement<\/span><\/p>\n<p><span style=\"font-family: courier new,courier; font-size: small;\">Function\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Remove-PrinterPort\u00a0\u00a0\u00a0\u00a0 PrintManagement<\/span><\/p>\n<p><span style=\"font-family: courier new,courier; font-size: small;\">Function\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Rename-Printer\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 PrintManagement<\/span><\/p>\n<p><span style=\"font-family: courier new,courier; font-size: small;\">Function\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Set-Printer\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 PrintManagement<\/span><\/p>\n<p><span style=\"font-family: courier new,courier; font-size: small;\">Function\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Set-PrinterProperty\u00a0\u00a0\u00a0 PrintManagement<\/span><\/p>\n<p><span style=\"font-family: courier new,courier; font-size: small;\">Cmdlet\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Out-Printer\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Microsoft.PowerShell.Utility<\/span><\/p>\n<p><span style=\"font-family: Calibri; font-size: small;\">\u00a0<\/span><\/p>\n<p><span style=\"font-size: medium;\"><span style=\"font-family: Calibri;\">Notice the choice of the noun \u201cprinter\u201d, as opposed to the verb \u201cadd\u201d. \u201cAdd\u201d could be adding anything, so reducing the scope to \u201cprinter\u201d allows for a more precise initial search.<\/span><\/span><\/p>\n<p><span style=\"font-family: Calibri; font-size: medium;\">For this simple case of adding a printer, it is very possible that the first guess would be \u201cadd-printer\u201d, 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.<\/span><\/p>\n<p><span style=\"font-family: Calibri; font-size: medium;\">The first * in *printer* allows finding cmdlets with any verb or noun prefix. By \u201cnoun prefix\u201d I mean the cmdlet developers could have called them <b>System<\/b>Printers, <b>PS<\/b>Printers, or other name. The second * allows for any noun suffix like \u201cDriver\u201d and \u201cProperty\u201d in the list above. <\/span><\/p>\n<p><span style=\"font-family: Calibri; font-size: medium;\">After looking at the list, we might conclude that we are not interested in \u201cPrinterDriver\u201d or \u201cPrinterPort\u201d 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.<\/span><\/p>\n<p><span style=\"font-family: Calibri; font-size: medium;\">After you found the cmdlet, you can explorer it a bit further with one of the following: <\/span><\/p>\n<p><span style=\"font-size: medium;\"><span style=\"font-family: Calibri;\">\u00a0\u00a0\u00a0\u00a0 get-help add-printer<\/span><span style=\"font-family: Calibri;\">\u00a0\u00a0 <\/span><\/span><\/p>\n<p><span style=\"font-size: medium;\"><span style=\"font-family: Calibri;\">\u00a0\u00a0\u00a0\u00a0 get-command add-printer<\/span><span style=\"font-family: Calibri;\">\u00a0<\/span><\/span><\/p>\n<h2><span style=\"font-size: large;\"><span style=\"color: #4f81bd;\"><span style=\"font-family: Cambria;\">Finding cmdlets with show-cmdlet<\/span><\/span><\/span><\/h2>\n<p><span style=\"font-family: Calibri; font-size: medium;\">We saw in <a title=\"Running show-command for a cmdlet\" href=\"http:\/\/blogs.msdn.com\/b\/powershell\/archive\/2012\/04\/13\/running-show-command-for-a-cmdlet.aspx\">Running show-command for a cmdlet<\/a>, how to use show-command for a specific cmdlet. If you run just \u201cshow-command\u201d this is what you get:<\/span><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2012\/06\/5554.a.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-20402\" src=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2012\/06\/5554.a.png\" alt=\"Image 5554 a\" width=\"376\" height=\"598\" srcset=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2012\/06\/5554.a.png 376w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2012\/06\/5554.a-189x300.png 189w\" sizes=\"(max-width: 376px) 100vw, 376px\" \/><\/a><\/p>\n<p><span style=\"font-family: Calibri; font-size: medium;\">Note:<\/span><\/p>\n<ul>\n<li><span style=\"font-family: Calibri; font-size: medium;\">\u00a0A \u201cModule\u201d is a set of cmdlets for a given domain. In this window you can see cmdlets from all modules, but you might filter the results to a specific module, in the \u201cModules\u201d drop down.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-family: Calibri; font-size: medium;\">\u00a0<\/span><\/p>\n<p><span style=\"font-family: Calibri; font-size: medium;\">If then you type \u201cprinter\u201d under Name, you have:<\/span><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2012\/06\/1616.a.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-20404\" src=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2012\/06\/1616.a.png\" alt=\"Image 1616 a\" width=\"376\" height=\"598\" srcset=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2012\/06\/1616.a.png 376w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2012\/06\/1616.a-189x300.png 189w\" sizes=\"(max-width: 376px) 100vw, 376px\" \/><\/a><\/p>\n<p><span style=\"font-size: medium;\"><span style=\"font-family: Calibri;\">\u00a0<\/span><span style=\"font-family: Calibri;\">Notice that *printer* is implicit. If the cmdlet contains printer, you will see it.<\/span><\/span><\/p>\n<p><span style=\"font-size: medium;\"><span style=\"font-family: Calibri;\">\u00a0<\/span><span style=\"font-family: Calibri;\">If you had typed printers, you would see the same list, because the search results also include the singular form of what you typed.<\/span><\/span><\/p>\n<p align=\"left\"><span style=\"font-size: medium;\"><span style=\"font-family: Calibri;\">\u00a0<\/span><span style=\"font-family: Calibri;\">When you click the Add-Printer cmdlet you get the window on the left below, and after you click \u201cShow-Details\u201d you get the window on the right:<\/span><\/span><\/p>\n<p align=\"left\"><a href=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2012\/06\/1667.a.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-20405\" src=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2012\/06\/1667.a.png\" alt=\"Image 1667 a\" width=\"567\" height=\"442\" srcset=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2012\/06\/1667.a.png 567w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2012\/06\/1667.a-300x234.png 300w\" sizes=\"(max-width: 567px) 100vw, 567px\" \/><\/a><\/p>\n<p align=\"left\"><span style=\"font-family: Calibri; font-size: medium;\">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.<\/span><\/p>\n<p><span style=\"font-size: medium;\"><span style=\"font-family: Calibri;\">\u00a0<\/span><span style=\"font-family: Calibri;\">Notes: <\/span><\/span><\/p>\n<ul>\n<li><span style=\"font-family: Calibri; font-size: medium;\">The \u201cAdd-Printer\u201d section of the window is the same we would see if we had typed \u201cshow-command add-printer\u201d and that part is explored a bit more in <a title=\"Running show-command for a cmdlet\" href=\"http:\/\/blogs.msdn.com\/b\/powershell\/archive\/2012\/04\/13\/running-show-command-for-a-cmdlet.aspx\">Running show-command for a cmdlet<\/a>.<\/span><\/li>\n<li><span style=\"font-family: Calibri; font-size: medium;\">The same window as the one displayed for \u201cshow-command\u201d is also embedded in \u201cPowerShell ISE\u201d by default and can be seen in the \u201cView &#8211; Show Command Add-on\u201d menu when not present. To start ISE, type <span style=\"color: #808080;\">ise<\/span>\u00a0in a PowerShell console and press Enter.<\/span><\/li>\n<li><span style=\"font-family: Calibri; font-size: medium;\">If the cmdlet module is already imported, you will not see the \u201cShow Details\u201d button. <\/span><\/li>\n<li><span style=\"font-size: medium;\"><span style=\"font-family: Calibri;\">For a cmdlet belonging to a module that was not yet imported, we had 2 alternatives: starting to load the module as soon as Add-Printer is selected, or using the intermediary \u201cShow Details\u201d text you see on the left. We decided for the intermediate step to give the user a chance to understand a module is going to be imported and explicitly choose to do that. We were not comfortable with the idea of selecting list items with mouse or keyboard resulting in modules being loaded implicitly.<\/span><\/span><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><span style=\"font-size: medium;\"><span style=\"font-family: Calibri;\">Lucio Silveira [MSFT]<\/span><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This blog post applies to the Windows PowerShell\u00a0Version 3.0.\u00a0 Problem: How can I find out what cmdlets are available for a given task?\u00a0 Finding cmdlets in the traditional way \u00a0If 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 [&hellip;]<\/p>\n","protected":false},"author":600,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2311","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell"],"acf":[],"blog_post_summary":"<p>This blog post applies to the Windows PowerShell\u00a0Version 3.0.\u00a0 Problem: How can I find out what cmdlets are available for a given task?\u00a0 Finding cmdlets in the traditional way \u00a0If 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 [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/2311","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/users\/600"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=2311"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/2311\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media\/13641"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media?parent=2311"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=2311"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=2311"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}