{"id":77271,"date":"2016-02-23T00:01:04","date_gmt":"2016-02-23T08:01:04","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/?p=77271"},"modified":"2022-04-21T13:23:45","modified_gmt":"2022-04-21T20:23:45","slug":"overview-of-the-powershell-get-module-to-find-scripts","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/overview-of-the-powershell-get-module-to-find-scripts\/","title":{"rendered":"Overview of the PowerShellGet module to find scripts"},"content":{"rendered":"<p><strong>Summary<\/strong>: In this blog post, I provide a quick overview of the <strong>PowerShellGet<\/strong> module and its various commands.<\/p>\n<p>Believe it or not, the <a href=\"http:\/\/powershellsaturday.com\/010\/\" target=\"_blank\" rel=\"noopener\">Windows PowerShell Saturday event in Tampa, Florida<\/a> is coming up pretty quickly. There are still some tickets available, but they have been going pretty quickly lately. There are some awesome speakers coming to Tampa for this event and I am looking forward to seeing all of them. Something really cool is that Ashley McGlone is coming from Columbus, Ohio for the event. I was his mentor for a couple of years, and it is really great to see how successful he has become. In fact, we are getting together after the PowerShell Summit in Seattle to record a couple sessions for a <a href=\"https:\/\/mva.microsoft.com\/\" target=\"_blank\" rel=\"noopener\">Microsoft Virtual Academy<\/a> (MVA) course. Several speakers from Tampa will also be involved in this project. I can say that we have a blue ribbon roster of speakers for our event in Tampa\u2014all of whom are well known in the Windows PowerShell community. Ashley asked me to talk a bit about the <strong>PowerShellGet<\/strong> module and package management in Windows PowerShell for the MVA course we will be doing. With this in mind, I have been playing with Windows <strong>PowerShellGet<\/strong> more.<\/p>\n<h2>Explore the PowerShell Get module<\/h2>\n<p>The first thing that I do when I am looking at something new, or when I want to refresh my memory about something is to look at the module. Because most stuff in Windows PowerShell ships in a module now, it is always a safe bet that there is a module. I can use<\/p>\n<p><strong>Get-Module<\/strong> to list all modules, and then I can search through the list. But in this case, I happen to know that the module is <strong>PowerShellGet<\/strong>, so I don\u2019t need to do that. I type the following command, but the results are a bit muddled because the <strong>ExportedCommands<\/strong> is a collection, and it needs to be expanded to make more sense.<\/p>\n<pre><code>  PS C:\\&gt; Get-Module PowerShellGet | select ExportedCommands\n\n  ExportedCommands\n  ----------------\n  {[Find-DscResource, Find-DscResource], [Find-Module, Find-Module], [Find-Script, ...\n<\/code><\/pre>\n<p>The easy way to do this is to use the <strong>Expand<\/strong> parameter from <strong>Select-Object<\/strong>. Here is the command I use:<\/p>\n<pre><code>  Get-Module PowerShellGet | select -EXPAND ExportedCommands\n<\/code><\/pre>\n<p>The command and its output are shown here:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/HSG-2-23-16-01.png\"><img decoding=\"async\" class=\"alignnone size-medium wp-image-77291\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/HSG-2-23-16-01-300x248.png\" alt=\"Image of command output\" width=\"300\" height=\"248\" \/><\/a><\/p>\n<p>From the list of commands, I can see that the first thing I might need to do is to see if I have a registered Windows PowerShell repository. The cmdlet I use is <strong>Get-PSRepository<\/strong>:<\/p>\n<pre><code>  PS C:\\&gt; Get-PSRepository\n\n  Name \u00a0 \u00a0      PackageManagementProvider InstallationPolicy\u00a0\u00a0 SourceLocation\n  ---- \u00a0 \u00a0      ------------------------- ------------------\u00a0\u00a0 -----------\n  PSGallery\u00a0\u00a0\u00a0\u00a0\u00a0NuGet\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Untrusted\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 https:\/\/...\n<\/code><\/pre>\n<p>Again, the output is a bit truncated, so I decide to pipe the output to <strong>Format-List<\/strong>:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/HSG-2-23-16-02.png\"><img decoding=\"async\" class=\"alignnone size-medium wp-image-77301\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/HSG-2-23-16-02-300x173.png\" alt=\"Image of command output\" width=\"300\" height=\"173\" \/><\/a><\/p>\n<p>Cool. I can see that I have registered the PSGallery and that it uses NuGet as the package management provider. I also see the publish location and other locations. It is not a trusted location and the installation policy is listed as untrusted. Sweet.<\/p>\n<h2>Finding scripts<\/h2>\n<p>I saw that there is a <strong>Find-Script<\/strong> command. I also see that there is a script publish and source location in the PSGallery, so I can probably use <strong>Find-Script<\/strong> to find a script. I happen to know that one reason for this is so I can easily use script resources with <a href=\"https:\/\/blogs.technet.microsoft.com\/msoms\/\" target=\"_blank\" rel=\"noopener\">OMS automation<\/a>. Right now, it is not unreasonable to simply use <strong>Find-Script<\/strong> with no parameters and look at the output. There are not that many scripts published to PSGallery at this point. Here is the output from the command:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/HSG-2-23-16-03.png\"><img decoding=\"async\" class=\"alignnone size-medium wp-image-77311\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/HSG-2-23-16-03-300x196.png\" alt=\"Image of command output\" width=\"300\" height=\"196\" \/><\/a><\/p>\n<p>But if I have an idea as to what I am interested in finding, I can use wildcard characters after <strong>Find-Script<\/strong>. Here, I look for a script that may have the letters <strong>automat<\/strong> in the name:<\/p>\n<pre><code>PS C:\\&gt; Find-Script *automat*\n\nVersion\u00a0\u00a0\u00a0 Name \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0         Type\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Repository\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Description\n-------\u00a0\u00a0\u00a0 ----\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ----\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0----------\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 -----\n1.0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Start-AutomationChildRunbook\u00a0\u00a0\u00a0\u00a0\u00a0Script\u00a0\u00a0\u00a0\u00a0 PSGallery\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Th...\n1.0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Create-AutomationReport\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Script\u00a0\u00a0\u00a0\u00a0 PSGallery\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Th...\n<\/code><\/pre>\n<p>Once again, I have the truncated output. I am most interested in the name and description. I use \n<strong>Format-Table<\/strong> and <strong>-Wrap<\/strong> to help me get better output:<\/p>\n<pre><code>Find-Script *automat* | Format-Table name, description -Wrap\n<\/code><\/pre>\n<p>This command and its output are shown here:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/HSG-2-23-16-04.png\"><img decoding=\"async\" class=\"alignnone size-medium wp-image-77281\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/HSG-2-23-16-04-300x196.png\" alt=\"Image of command output\" width=\"300\" height=\"196\" \/><\/a><\/p>\n<p>Join me tomorrow when I will talk about finding DSC resources. I invite you to follow me on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\" target=\"_blank\" rel=\"noopener\">Facebook<\/a>. If you have any questions, send email to me at <a href=\"&#109;&#97;&#x69;&#x6c;&#116;&#111;&#x3a;&#x73;c&#114;&#105;&#x70;&#x74;&#101;&#114;&#x40;&#x6d;&#105;&#99;&#x72;&#x6f;s&#111;&#102;&#x74;&#x2e;&#99;&#111;&#x6d;\">&#x73;c&#114;&#105;&#x70;&#x74;&#101;&#114;&#x40;&#x6d;&#105;&#99;&#x72;&#x6f;s&#111;&#102;&#x74;&#x2e;&#99;&#111;&#x6d;<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\" target=\"_blank\" rel=\"noopener\">Official Scripting Guys Forum<\/a>. Also check out my <a href=\"https:\/\/blogs.technet.microsoft.com\/msoms\/\" target=\"_blank\" rel=\"noopener\">Microsoft Operations Management Suite Blog<\/a>. See you tomorrow. Until then, peace. <strong>Ed Wilson, Microsoft Scripting Guy<\/strong> \u00a0 \u00a0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: In this blog post, I provide a quick overview of the PowerShellGet module and its various commands. Believe it or not, the Windows PowerShell Saturday event in Tampa, Florida is coming up pretty quickly. There are still some tickets available, but they have been going pretty quickly lately. There are some awesome speakers coming [&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":[568],"tags":[51,666,3,45],"class_list":["post-77271","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-hey-scripting-guy","tag-getting-started","tag-powershell-get","tag-scripting-guy","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: In this blog post, I provide a quick overview of the PowerShellGet module and its various commands. Believe it or not, the Windows PowerShell Saturday event in Tampa, Florida is coming up pretty quickly. There are still some tickets available, but they have been going pretty quickly lately. There are some awesome speakers coming [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/77271","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=77271"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/77271\/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=77271"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=77271"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=77271"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}