{"id":1569,"date":"2014-04-20T00:01:00","date_gmt":"2014-04-20T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2014\/04\/20\/weekend-scripter-exploring-powershell-modules\/"},"modified":"2014-04-20T00:01:00","modified_gmt":"2014-04-20T00:01:00","slug":"weekend-scripter-exploring-powershell-modules","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/weekend-scripter-exploring-powershell-modules\/","title":{"rendered":"Weekend Scripter: Exploring PowerShell Modules"},"content":{"rendered":"<p><b>Summary<\/b>: Use Windows PowerShell to explore Windows PowerShell modules.<\/p>\n<p>Microsoft Scripting Guy, Ed Wilson, is here. One of the things I really, really, really like about Windows PowerShell is the fact that it is self-discoverable. I mean, I can use Windows PowerShell to explore Windows PowerShell and to learn about Windows PowerShell.<\/p>\n<p>One of the neat features introduced in Windows PowerShell&nbsp;3.0 was the automatic loading of Windows PowerShell modules. This was an essential feature given the explosion of Windows PowerShell modules that shipped with Windows&nbsp;8 and Windows Server&nbsp;2012. In Windows PowerShell&nbsp;2.0 in Windows 7, I had a good feel for all the different modules, snap-ins, and the cmdlets. But with Windows PowerShell 3.0, the number of cmdlets, functions, and modules grew to the point where I am still finding new things I have not yet tried, and we are already into version 4.0 in Windows 8.1.<\/p>\n<h2>Opening the module to explore<\/h2>\n<p>The first thing that I like to do is to produce a list of available modules. To do that, I use the <b>Get-Module<\/b> cmdlet with the <b>&ndash;ListAvailable<\/b> switch as shown here (I like to use the alias <b>gmo<\/b> <b>&ndash;l<\/b> when I am doing this):<\/p>\n<p style=\"margin-left:30px\">Get-Module -ListAvailable<\/p>\n<p>The command and the output from the command are shown here:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/wes-4-20-14-01.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/wes-4-20-14-01.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>In the previous image, I can see that there are many modules located in different folders. I decide to select the path to the modules and to use the <b>Split-Path<\/b> cmdlet to view the parent folder. The first time I do it, the module folder itself returns. So I add an additional <b>Split-Path<\/b> command, and now I can see how modules reside in the various module locations. This is shown here:<\/p>\n<p style=\"margin-left:30px\">PS C:\\&gt; Get-Module -ListAvailable | select path | Split-Path -Parent | Split-Path &ndash;Parent |<\/p>\n<p style=\"margin-left:30px\">group -NoElement<\/p>\n<p style=\"margin-left:30px\">Count Name<\/p>\n<p style=\"margin-left:30px\">&#8212;&#8211; &#8212;-<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp; 4 C:\\Users\\ed\\Documents\\&#8230;<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp; 61 C:\\WINDOWS\\system32\\Wi&#8230;<\/p>\n<p style=\"margin-left:30px\">&nbsp;&nbsp;&nbsp; 1 C:\\Program Files\\Share&#8230;<\/p>\n<p>Most of the modules are in the default Windows PowerShell location. Only a few are in my Users location. One is in the strange SharePoint folder.<\/p>\n<h2>Looking at a specific module<\/h2>\n<p>I decide I want to look at a specific module: the <b>wdac<\/b> module. The first thing to do is to load the module. To do this, I use the <b>Import-Module<\/b> cmdlet (<b>ipmo<\/b> is the alias for this command). The command is shown here:<\/p>\n<p style=\"margin-left:30px\">Import-Module wdac<\/p>\n<p>Nothing returns when I import the module. But if I use the <b>&ndash;Verbose<\/b> switch, I can see what the module does:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/wes-4-20-14-02.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/wes-4-20-14-02.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<h2>What&rsquo;s in the module<\/h2>\n<p>When the module is imported, the <b>Get-Module<\/b> cmdlet returns information about the <b>wdac<\/b> module. The command is shown here:<\/p>\n<p style=\"margin-left:30px\">Get-Module wdac<\/p>\n<p>And here is the output from this command:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/wes-4-20-14-03.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/wes-4-20-14-03.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>The output is not extremely interesting. It does tell me that there is a manifest and the module is version&nbsp;1.0. But there is more information available. To see that information, I pipe the output to the <b>Format-List<\/b> cmdlet (<b>FL<\/b> is an alias that I could use for <b>Format-List<\/b>):<\/p>\n<p style=\"margin-left:30px\">Get-Module wdac | Format-List *<\/p>\n<p>The command and the output from the command are shown in the image that follows:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/wes-4-20-14-04.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/wes-4-20-14-04.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>There are some pretty interesting things available in the output. For instance, I can see the author of the module and the version of Windows PowerShell that is required. I see that the exported commands are functions, not cmdlets. I can list the functions by using dotted notation, as shown here:<\/p>\n<p style=\"margin-left:30px\">PS C:\\&gt; (gmo wdac).ExportedFunctions<\/p>\n<p style=\"margin-left:30px\">Key&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Value<\/p>\n<p style=\"margin-left:30px\">&#8212;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8211;<\/p>\n<p style=\"margin-left:30px\">Add-OdbcDsn&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Add-OdbcDsn<\/p>\n<p style=\"margin-left:30px\">Disable-OdbcPerfCounter&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Disable-OdbcPerfCounter<\/p>\n<p style=\"margin-left:30px\">Disable-WdacBidTrace&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Disable-WdacBidTrace<\/p>\n<p style=\"margin-left:30px\">Enable-OdbcPerfCounter&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Enable-OdbcPerfCounter<\/p>\n<p style=\"margin-left:30px\">Enable-WdacBidTrace&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Enable-WdacBidTrace<\/p>\n<p style=\"margin-left:30px\">Get-OdbcDriver&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Get-OdbcDriver<\/p>\n<p style=\"margin-left:30px\">Get-OdbcDsn&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;Get-OdbcDsn<\/p>\n<p style=\"margin-left:30px\">Get-OdbcPerfCounter&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Get-OdbcPerfCounter<\/p>\n<p style=\"margin-left:30px\">Get-WdacBidTrace&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Get-WdacBidTrace<\/p>\n<p style=\"margin-left:30px\">Remove-OdbcDsn&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Remove-OdbcDsn<\/p>\n<p style=\"margin-left:30px\">Set-OdbcDriver&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set-OdbcDriver<\/p>\n<p style=\"margin-left:30px\">Set-OdbcDsn&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set-OdbcDsn<\/p>\n<p>I also see that there is a format file. The path to the format file is:<\/p>\n<p style=\"margin-left:30px\">PS C:\\&gt; (gmo wdac).ExportedFormatFiles<\/p>\n<p style=\"margin-left:30px\">C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules\\wdac\\Wdac.format.ps1xml<\/p>\n<p>I can open that file in Notepad as shown here:<\/p>\n<p style=\"margin-left:30px\">notepad (gmo wdac).ExportedFormatFiles<\/p>\n<p>When the command runs, the following output appears:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/wes-4-20-14-05.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/wes-4-20-14-05.png\" alt=\"Image of command output\" title=\"Image of command output\" \/><\/a><\/p>\n<p>Cool stuff. Take some time to explore other modules that may be interesting to you. Hey, it is the weekend (at least here in Charlotte, North Carolina), and weekends were made for Windows PowerShell exploration. Join me tomorrow when I kick off a poshpourri week.<\/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>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Use Windows PowerShell to explore Windows PowerShell modules. Microsoft Scripting Guy, Ed Wilson, is here. One of the things I really, really, really like about Windows PowerShell is the fact that it is self-discoverable. I mean, I can use Windows PowerShell to explore Windows PowerShell and to learn about Windows PowerShell. One of the [&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":[51,3,4,61,45],"class_list":["post-1569","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-getting-started","tag-scripting-guy","tag-scripting-techniques","tag-weekend-scripter","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Use Windows PowerShell to explore Windows PowerShell modules. Microsoft Scripting Guy, Ed Wilson, is here. One of the things I really, really, really like about Windows PowerShell is the fact that it is self-discoverable. I mean, I can use Windows PowerShell to explore Windows PowerShell and to learn about Windows PowerShell. One of the [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/1569","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=1569"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/1569\/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=1569"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=1569"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=1569"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}