{"id":207,"date":"2014-12-13T00:01:00","date_gmt":"2014-12-13T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2014\/12\/13\/weekend-scripter-a-graphical-tool-to-explore-powershell-help\/"},"modified":"2019-02-18T10:36:36","modified_gmt":"2019-02-18T17:36:36","slug":"weekend-scripter-a-graphical-tool-to-explore-powershell-help","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/weekend-scripter-a-graphical-tool-to-explore-powershell-help\/","title":{"rendered":"Weekend Scripter: A Graphical Tool to Explore PowerShell Help"},"content":{"rendered":"<p align=\"left\"><b>Summary<\/b>: Microsoft Scripting Guy, Ed Wilson, talks about using Windows PowerShell to explore Help topics.<\/p>\n<p>Microsoft Scripting Guy, Ed Wilson, is here. With the drops of the <a href=\"http:\/\/blogs.msdn.com\/b\/powershell\/archive\/2014\/11\/18\/windows-management-framework-5-0-preview-november-2014-is-now-available.aspx\" target=\"_blank\">Windows Management Framework&nbsp;5.0<\/a> (also known as Windows PowerShell&nbsp;5.0), now is a good time to begin exploring modules, new cmdlets, and so on. It is way cool that Windows PowerShell is largely self-documenting and that it has tools that make it easy to discover features and use them.<\/p>\n<p style=\"margin-left:30px\"><b>Note&nbsp;<\/b> The script today works in Windows PowerShell&nbsp;4.0 and Windows PowerShell&nbsp;3.0. It does not take advantage of any new features of Windows PowerShell&nbsp;5.0, but it also works there. It does not work in Windows PowerShell&nbsp;2.0 because <b>Out-GridView<\/b> did not contain a <b>&ndash;Passthru<\/b> parameter in that version.<\/p>\n<p>I am spending a lot of time these days playing around with Windows PowerShell&nbsp;5.0. Because it is not yet released, at times, I need to get old school when it comes to working with the product and rely upon the cmdlet help. There are a few blog posts about it from the <a href=\"http:\/\/blogs.msdn.com\/b\/powershell\" target=\"_blank\">Windows PowerShell team<\/a> and some from various MVPs&mdash;but that is about it. Luckily the documentation team has been steadily documenting the product and so I can use help.<\/p>\n<p>So that means that I need to figure out things for myself. I wrote a script that allows me to specify a particular module with the <b>Get-Command<\/b> cmdlet. I pipe the results to <b>Out-GridView<\/b>, and then I take the cmdlet I select from <b>Out-GridView<\/b> and pass it to <b>Get-Help<\/b>.<\/p>\n<p>It is a pretty useful script, and passing selected items from <b>Out-GridView<\/b> is a good technique to use because it essentially permits one to make a graphical tool very quickly.<\/p>\n<p>If I wanted to, I could turn this into a function in about 30 seconds&mdash;but it is not something I feel like doing at this time. I would specify an input parameter for my module name, and maybe add a parameter to permit only full examples or standard Help output. But like I said, it is not something I feel a real need to do. Using it directly from the Windows PowerShell ISE is fine for what it is.<\/p>\n<p>The first thing I do is specify a variable to hold the module name. This makes it pretty easy to switch modules if I need to do so. Next I use the <b>Get-Command<\/b> cmdlet to find all the cmdlets and other commands in the specific module. This is shown here:<\/p>\n<p style=\"margin-left:30px\">$m = &quot;hyper-v&quot;<\/p>\n<p style=\"margin-left:30px\">Get-Command -Module $m |&nbsp;<\/p>\n<p>The next thing I do is use the <b>Select-Object<\/b> cmdlet to choose a few particular properties from the <b>CmdletInfo<\/b> object that is returned via the <b>Get-Command<\/b> cmdlet. I select the name, verb, noun, and the definition parameters:<\/p>\n<p style=\"margin-left:30px\">Select-Object name, verb, noun, definition |<\/p>\n<p>I pipe the object to the <b>Out-GridView<\/b> cmdlet. I specify a title that includes the module name, and I use the <b>&ndash;Passthru<\/b> parameter. This is important because it pauses the execution of the script, and it waits until I select a cmdlet from the grid view list. After I make a selection, it passes the resulting object down the pipeline. Here is the command:<\/p>\n<p style=\"margin-left:30px\">Out-GridView -Title &quot;Cmdlets from the $m module&quot; -PassThru |<\/p>\n<p>The last thing I do is send the output from <b>Out-GridView<\/b> to the <b>Get-Help<\/b> cmdlet. The complete script is shown here:<\/p>\n<p style=\"margin-left:30px\">$m = &quot;hyper-v&quot;<\/p>\n<p style=\"margin-left:30px\">Get-Command -Module $m |<\/p>\n<p style=\"margin-left:30px\">Select-Object name, verb, noun, definition |<\/p>\n<p style=\"margin-left:30px\">Out-GridView -Title &quot;Cmdlets from the $m module&quot; -PassThru |<\/p>\n<p style=\"margin-left:30px\">Get-Help&nbsp;&nbsp;<\/p>\n<p>As seen here, when I run the script, the output first appears in a grid:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-12-13-14-01.png\"><img decoding=\"async\" title=\"Image of command output\" alt=\"Image of command output\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-12-13-14-01.png\" \/><\/a><\/p>\n<p>When I press the <b>OK<\/b> button, the object moves down the pipeline to the <b>Get-Help<\/b> cmdlet. The output from the <b>Get-Help<\/b> command appears in the output of the Windows PowerShell ISE. This is shown here where I had selected <b>Add-VMHardDiskDrive<\/b> from the list in the <b>Out-GridView<\/b> grid:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-12-13-14-02.png\"><img decoding=\"async\" title=\"Image of command output\" alt=\"Image of command output\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/hsg-12-13-14-02.png\" \/><\/a><\/p>\n<p>And that is all there is to using <b>Out-GridView<\/b> to assist in exploring Windows PowerShell Help.<\/p>\n<p>I invite you to follow me on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\" target=\"_blank\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\" target=\"_blank\">Facebook<\/a>. If you have any questions, send email to me at <a href=\"mailto:scripter@microsoft.com\" target=\"_blank\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\" target=\"_blank\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.<\/p>\n<p><b>Ed Wilson, Microsoft Scripting Guy<\/b><span style=\"font-size:12px\">&nbsp;<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Microsoft Scripting Guy, Ed Wilson, talks about using Windows PowerShell to explore Help topics. Microsoft Scripting Guy, Ed Wilson, is here. With the drops of the Windows Management Framework&nbsp;5.0 (also known as Windows PowerShell&nbsp;5.0), now is a good time to begin exploring modules, new cmdlets, and so on. It is way cool that Windows [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[463,3,4,61,45],"class_list":["post-207","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-help","tag-scripting-guy","tag-scripting-techniques","tag-weekend-scripter","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Microsoft Scripting Guy, Ed Wilson, talks about using Windows PowerShell to explore Help topics. Microsoft Scripting Guy, Ed Wilson, is here. With the drops of the Windows Management Framework&nbsp;5.0 (also known as Windows PowerShell&nbsp;5.0), now is a good time to begin exploring modules, new cmdlets, and so on. It is way cool that Windows [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/207","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=207"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/207\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=207"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}