{"id":30674,"date":"2022-07-22T20:20:56","date_gmt":"2022-07-22T20:20:56","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=30674"},"modified":"2022-12-23T05:52:18","modified_gmt":"2022-12-23T05:52:18","slug":"powershellget-commands-reference","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/powershellget-commands-reference\/","title":{"rendered":"PowerShellGet Commands Reference"},"content":{"rendered":"\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"managing-resources-with-powershellget-v3\">Managing Resources with PowerShellGet v3<\/h2>\n\n\n\n<p>The cmdlet names have changed in PowerShellGet v3. Instead of&nbsp;<code>Install-Module<\/code>, you will use&nbsp;<code>Install-PSResource<\/code>. It\u2019s actually the same cmdlet for all resources such as scripts and DSC resources.<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">Install-PSResource -Name Universal\n<\/code><\/span><\/pre>\n\n\n<p>The&nbsp;<code>Install-PSResource<\/code>&nbsp;cmdlet supports similar parameters to&nbsp;<code>Install-Module<\/code>&nbsp;but have slightly different names and meanings.<\/p>\n\n\n\n<p>For example,&nbsp;<code>-AllowClobber<\/code>&nbsp;was optional in&nbsp;<code>Install-Module<\/code>&nbsp;but is now the default for&nbsp;<code>Install-PSResource<\/code>. You can use&nbsp;<code>-NoClobber<\/code>&nbsp;to change this behavior.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">Install-PSResource -Name dbatools -Version <span class=\"hljs-string\">'1.1.41'<\/span> -NoClobber\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\" id=\"changing-installation-scope\">Changing Installation Scope<\/h3>\n\n\n\n<p>The&nbsp;<code>-Scope<\/code>&nbsp;parameter can be used to install the module for&nbsp;<code>CurrentUser<\/code>&nbsp;or&nbsp;<code>AllUsers<\/code>.&nbsp;<code>CurrentUser<\/code>&nbsp;is the default setting. You will need to be running as administrator to install to all users.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">Install-PSResource -Name <span class=\"hljs-string\">'PSWindowsUpdate'<\/span> -Scope AllUsers\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\" id=\"installing-dsc-resources\">Installing DSC Resources<\/h3>\n\n\n\n<p>You can also install DSC resources with&nbsp;<code>Install-PSResource<\/code>. The syntax is very much the same as with modules.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">Install-PSResource -Name <span class=\"hljs-string\">'NetworkingDsc'<\/span>\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\" id=\"saving-a-module\">Saving a Module<\/h3>\n\n\n\n<p>Much like&nbsp;<code>Save-Module<\/code>, you can use&nbsp;<code>Save-PSResource<\/code>&nbsp;to download a module for deployment to offline machines or to save into your own repository.&nbsp;<code>Save-PSResource<\/code>&nbsp;supports parameters like&nbsp;<code>-AsNupkg<\/code>&nbsp;and&nbsp;<code>-IncludeXml<\/code>&nbsp;to change what is downloaded. NuPkg files are special ZIP files that contain manifest information and are used with the NuGet package management system.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css\"><span class=\"hljs-selector-tag\">Save-PSResource<\/span> <span class=\"hljs-selector-tag\">-Name<\/span> <span class=\"hljs-selector-tag\">Universal<\/span> <span class=\"hljs-selector-tag\">-AsNupkg<\/span> <span class=\"hljs-selector-tag\">-Path<\/span> .\\<span class=\"hljs-selector-tag\">universal<\/span><span class=\"hljs-selector-class\">.nupkg<\/span> \n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\" id=\"list-installed-modules\">List Installed Modules<\/h3>\n\n\n\n<p>You can use&nbsp;<code>Get-PSResource<\/code>&nbsp;to list modules, and other resources, that have been installed with PowerShellGet.<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">Get-PSResource\n<\/code><\/span><\/pre>\n\n\n<h3 class=\"wp-block-heading\" id=\"uninstall-a-module\">Uninstall a Module<\/h3>\n\n\n\n<p>You can use the&nbsp;<code>Uninstall-PSResource<\/code>&nbsp;cmdlet to uninstall a module.<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">Uninstall-PSResource -Name Universal\n<\/code><\/span><\/pre>\n\n\n<h3 class=\"wp-block-heading\" id=\"publish-a-module\">Publish a Module<\/h3>\n\n\n\n<p>You can publish modules, an other resources, to repositories using&nbsp;<code>Publish-PSResource<\/code>.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">Publish-PSResource -Path .\\universal -ApiKey <span class=\"hljs-string\">'Test'<\/span>\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id=\"working-with-repositories-in-powershellget-v3\">Working with Repositories in PowerShellGet v3<\/h2>\n\n\n\n<p>By default, you will have the PowerShell Gallery defined as a repository. It will not be trusted but you can use the&nbsp;<code>-TrustRepository<\/code>&nbsp;cmdlet on the&nbsp;<code>*-PSResource<\/code>&nbsp;cmdlets to avoid the prompt to trust the repository.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">Install-PSResource -Name <span class=\"hljs-string\">'PendingReboot'<\/span> -TrustRepository\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\" id=\"trust-a-repository\">Trust a Repository<\/h3>\n\n\n\n<p>You can trust a repository by using the&nbsp;<code>Set-PSResourceRepository<\/code>&nbsp;cmdlet. You won\u2019t be prompted to trust the repository with each call from now on.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-built_in\">Set<\/span>-PSResourceRepository -Name PSGallery -Trusted\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\" id=\"register-a-repository\">Register a Repository<\/h3>\n\n\n\n<p>You can register a repository by using the&nbsp;<code>Register-PSResourceRepository<\/code>&nbsp;cmdlet.<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">Register-PSResourceRepository -Name Local -URL \\\\server\\share\n<\/code><\/span><\/pre>\n\n\n<p>To reverse the change, use&nbsp;<code>Unregister-PSResourceRepository<\/code>.<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">Unregister-PSResourceRepository -Name Local\n<\/code><\/span><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id=\"find-resources-with-powershellget-v3\">Find Resources with PowerShellGet v3<\/h2>\n\n\n\n<p>To find resources with PowerShellGet, you\u2019ll use the&nbsp;<code>Find-PSResource<\/code>&nbsp;cmdlet.<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">Find-PSResource -Name Universal\n<\/code><\/span><\/pre>\n\n\n<h3 class=\"wp-block-heading\" id=\"find-resources-by-type\">Find Resources by Type<\/h3>\n\n\n\n<p>You can specify the&nbsp;<code>-Type<\/code>&nbsp;parameter to look for resources by type.<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">Find-PSResource -Name PSDscResources -Type DscResource\n<\/code><\/span><\/pre>\n\n\n<h3 class=\"wp-block-heading\" id=\"find-resources-by-tag\">Find Resources by Tag<\/h3>\n\n\n\n<p>You can use the&nbsp;<code>-Tag<\/code>&nbsp;parameter to look up resources with tags.<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">Find-PSResource -Tag universal-dashboard\n<\/code><\/span><\/pre>\n\n\n<h3 class=\"wp-block-heading\" id=\"find-resources-by-wildcard-search\">Find Resources by Wildcard Search<\/h3>\n\n\n\n<p>You can also use wildcard searches to find resources that contain a pattern.<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">Find-PSResource -Name Universal*\n<\/code><\/span><\/pre>\n\n\n<h2 class=\"wp-block-heading\" id=\"backwards-compatibility\">Backwards Compatibility<\/h2>\n\n\n\n<p>Since PowerShellGet v2 and v3 are very different, the PowerShell team has released a compatibility module so that you can continue to use the original syntax and commands.<\/p>\n\n\n\n<p>You\u2019ll need to install the&nbsp;<code>CompatPowerShellGet<\/code>&nbsp;module in order to use the previous commands with the new version of PowerShellGet.<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">Install-PSResource -Name CompatPowerShellGet \n<\/code><\/span><\/pre>\n\n\n<p>Now, you can use cmdlets like&nbsp;<code>Install-Module<\/code>&nbsp;and it will map the command to&nbsp;<code>Install-PSResource<\/code>&nbsp;automatically.<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">Install-Module -Name dbatools -AllowPrerelease\n<\/code><\/span><\/pre>\n\n\n<p>Internally, this executes the following.<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">Install-PSResource -Name dbatools -Prerelease\n<\/code><\/span><\/pre>\n\n\n<p>The command will work as expected but you will see a warning.<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">Install-Module -Name dbatools -AllowPrerelease\n<span class=\"hljs-attr\">WARNING<\/span>: The cmdlet <span class=\"hljs-string\">'Install-Module'<\/span> is deprecated, please use <span class=\"hljs-string\">'Install-PSResource'<\/span>.\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>","protected":false},"excerpt":{"rendered":"<p>Managing Resources with PowerShellGet v3 The cmdlet names have changed in PowerShellGet v3. Instead of&nbsp;Install-Module, you will use&nbsp;Install-PSResource. It\u2019s actually the same cmdlet for all resources such&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[2],"tags":[],"class_list":["post-30674","post","type-post","status-publish","format-standard","hentry","category-uncategorised"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/30674","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=30674"}],"version-history":[{"count":1,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/30674\/revisions"}],"predecessor-version":[{"id":30675,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/30674\/revisions\/30675"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=30674"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=30674"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=30674"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}