{"id":1671,"date":"2014-05-20T08:50:00","date_gmt":"2014-05-20T08:50:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/powershell\/2014\/05\/20\/setting-up-an-internal-powershellget-repository\/"},"modified":"2019-02-18T13:05:19","modified_gmt":"2019-02-18T20:05:19","slug":"setting-up-an-internal-powershellget-repository","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/setting-up-an-internal-powershellget-repository\/","title":{"rendered":"Setting up an Internal PowerShellGet Repository"},"content":{"rendered":"<div class=\"WordSection1\">\n<p class=\"MsoNormal\">At TechEd, we announced and released an early version of PowerShellGet: a package manager for PowerShell modules.&nbsp; The response was positive, and many people asked the same type of question:<\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<p class=\"MsoNormal\">&ldquo;Can I set up my own internal repository for PowerShellGet?&rdquo;<\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<p class=\"MsoNormal\">Many enterprise-oriented houses want the ability to create private module repositories (without sharing them with the world).&nbsp; Many security minded folks want to curate their own module collections.<\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<p class=\"MsoNormal\">The short answer to this question is: yes!&nbsp; All you need to do is create your own NuGet Server and redefine a couple of PowerShellGet variables.&nbsp; Detailed instructions are below.<\/p>\n<h2>Diversion: Why NuGet?<\/h2>\n<p class=\"MsoNormal\">You might be asking yourself: &ldquo;Why does PowerShellGet work against NuGet Feeds?&rdquo; When designing PowerShellGet, we didn&rsquo;t want to reinvent the wheel.&nbsp; Making a good package manager from scratch can be hard.&nbsp; Fortunately, Microsoft already has a pretty awesome package management solution in NuGet (<a href=\"http:\/\/www.nuget.org\/\">http:\/\/www.nuget.org\/<\/a>).&nbsp; So, we decided to build PowerShellGet on top of NuGet.<\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<p class=\"MsoNormal\">This way, we can craft a PowerShell specific package management experience without needing to develop stuff like the protocol from scratch.&nbsp;<\/p>\n<h2>What does this mean for you?<\/h2>\n<p class=\"MsoNormal\">This means that PowerShellGet can work against any NuGet repository out of the box.&nbsp; <strong><em>Note: Do not publish PowerShell modules to NuGet.org.&nbsp; <\/em><\/strong><\/p>\n<p class=\"MsoNormal\"><strong><em><br \/><\/em><\/strong><\/p>\n<p class=\"MsoNormal\">The only things you need to do to make this happen are:<\/p>\n<ol>\n<li>Create a NuGet repository.<\/li>\n<li>Tell PowerShellGet to work against it.<\/li>\n<\/ol>\n<h2>Creating a NuGet Repository<\/h2>\n<p class=\"MsoNormal\">There are many ways to set up a working NuGet repository.&nbsp; Here are a couple of options:<\/p>\n<ol>\n<li>Follow the instructions in NuGet&rsquo;s documentation:<\/li>\n<ol>\n<li><a href=\"https:\/\/github.com\/NuGet\/NuGetGallery\">Setting up a Local Gallery<\/a><\/li>\n<li><a href=\"http:\/\/docs.nuget.org\/docs\/contribute\/branding-the-nuget-gallery\">Branding the NuGet Gallery<\/a><\/li>\n<\/ol>\n<li>Let a company like MyGet to host a NuGet feed for you (<a href=\"https:\/\/www.myget.org\/\">https:\/\/www.myget.org\/<\/a>).<\/li>\n<\/ol>\n<div class=\"WordSection1\"><em>Update: Commenters have also suggested the following links for help with setting up an internal repository:<\/em><\/div>\n<div class=\"WordSection1\">\n<ul>\n<li><a href=\"http:\/\/learn-powershell.net\/2014\/04\/11\/setting-up-a-nuget-feed-for-use-with-oneget\/\">http:\/\/learn-powershell.net\/2014\/04\/11\/setting-up-a-nuget-feed-for-use-with-oneget\/<\/a><\/li>\n<li><a href=\"http:\/\/asaconsultant.blogspot.no\/2014\/05\/build-your-local-powershell-module.html\">http:\/\/asaconsultant.blogspot.no\/2014\/05\/build-your-local-powershell-module.html<\/a><\/li>\n<\/ul>\n<\/div>\n<p class=\"MsoNormal\">For the purposes of this blog, I&rsquo;m going to use MyGet to create a NuGet feed.&nbsp; I ended up with a feed at this URL: <a href=\"https:\/\/www.myget.org\/F\/powershellgetdemo\/\">https:\/\/www.myget.org\/F\/powershellgetdemo\/<\/a>.<\/p>\n<h2>Tell PowerShellGet to work with your Repository<\/h2>\n<p class=\"MsoNormal\">For this release, PowerShellGet uses two variables to determine which gallery to work against: $PSGallerySourceUri and $PSGalleryPublishUri.&nbsp; Here&rsquo;s what you need to do to generate these variables for your feed:<\/p>\n<ol>\n<li>Append &ldquo;api\/v2&rdquo; to your feed URL for $PSGallerySourceUri (e.g. <a href=\"https:\/\/www.myget.org\/F\/powershellgetdemo\/api\/v2\">https:\/\/www.myget.org\/F\/powershellgetdemo\/api\/v2<\/a><\/li>\n<li>Append &ldquo;\/api\/v2\/package&rdquo; to your feed URL for $PSGalleryPublishUri (e.g. <a href=\"https:\/\/www.myget.org\/F\/powershellgetdemo\/api\/v2\/package\">https:\/\/www.myget.org\/F\/powershellgetdemo\/api\/v2\/package<\/a>)<\/li>\n<\/ol>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<p class=\"MsoNormal\">To make PowerShellGet work against these variables, you need to first import the PSGet module, <em>and then<\/em> override the values before using PSGet commands.&nbsp;<\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<p class=\"MsoNormal\">Here&rsquo;s an example:<\/p>\n<p class=\"MsoNormal\" style=\"background: #012456\"><span style=\"font-size: 9.0pt;line-height: 107%;font-family: 'Lucida Console';color: whitesmoke\">C:\\Windows\\System32\\WindowsPowerShell\\v1.0&gt; Import-Module PowerShellGet <\/span><\/p>\n<p class=\"MsoNormal\" style=\"background: #012456\"><span style=\"font-size: 9.0pt;line-height: 107%;font-family: 'Lucida Console';color: whitesmoke\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"background: #012456\"><span style=\"font-size: 9.0pt;line-height: 107%;font-family: 'Lucida Console';color: whitesmoke\">C:\\Windows\\System32\\WindowsPowerShell\\v1.0&gt; $PSGalleryPublishUri = &#8216;https:\/\/www.myget.org\/F\/powershellgetdemo\/api\/v2\/package&#8217;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"background: #012456\"><span style=\"font-size: 9.0pt;line-height: 107%;font-family: 'Lucida Console';color: whitesmoke\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"background: #012456\"><span style=\"font-size: 9.0pt;line-height: 107%;font-family: 'Lucida Console';color: whitesmoke\">C:\\Windows\\System32\\WindowsPowerShell\\v1.0&gt; $PSGallerySourceUri = &#8216;https:\/\/www.myget.org\/F\/powershellgetdemo\/api\/v2&#8217; <\/span><\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<h2>Success!<\/h2>\n<p class=\"MsoNormal\">You can successfully publish and install modules from your new NuGet gallery.<\/p>\n<p class=\"MsoNormal\" style=\"background: #012456\"><span style=\"font-size: 9.0pt;line-height: 107%;font-family: 'Lucida Console';color: whitesmoke\">C:\\Windows\\System32\\WindowsPowerShell\\v1.0&gt; Publish-Module -Name xDscResourceDesigner -NuGetApiKey wouldnt-you-like-to-know&hellip; <\/span><\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<p class=\"MsoNormal\" style=\"background: #012456\"><span style=\"font-size: 9.0pt;line-height: 107%;font-family: 'Lucida Console';color: whitesmoke\">C:\\Windows\\System32\\WindowsPowerShell\\v1.0&gt; Find-Module xDscResourceDesigner<\/span><\/p>\n<p class=\"MsoNormal\" style=\"background: #012456\"><span style=\"font-size: 9.0pt;line-height: 107%;font-family: 'Lucida Console';color: whitesmoke\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\" style=\"background: #012456\"><span style=\"font-size: 9.0pt;line-height: 107%;font-family: 'Lucida Console';color: whitesmoke\">Version&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Name&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; DateUpdated&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Description&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/p>\n<p class=\"MsoNormal\" style=\"background: #012456\"><span style=\"font-size: 9.0pt;line-height: 107%;font-family: 'Lucida Console';color: whitesmoke\">&#8212;&#8212;-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#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; &#8212;&#8212;&#8212;&#8211;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8212;&#8212;&#8212;&#8211;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/span><\/p>\n<p class=\"MsoNormal\" style=\"background: #012456\"><span style=\"font-size: 9.0pt;line-height: 107%;font-family: 'Lucida Console';color: whitesmoke\">1.1.1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xDSCResourceDesigner&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5\/15\/2014 12:51:24 AM&nbsp;&nbsp;&nbsp;&nbsp; The xDscResour&#8230; <\/span><\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<h2>Looking forward<\/h2>\n<p class=\"MsoNormal\">As always, if you have feedback about PowerShellGet or any other PowerShell feature, please let us know: <a href=\"http:\/\/connect.microsoft.com\/PowerShell\">http:\/\/connect.microsoft.com\/PowerShell<\/a>.<\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<p class=\"MsoNormal\">John Slack<\/p>\n<p class=\"MsoNormal\">Program Manager<\/p>\n<p class=\"MsoNormal\">PowerShell Team<\/p>\n<p class=\"MsoNormal\">&nbsp;<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>At TechEd, we announced and released an early version of PowerShellGet: a package manager for PowerShell modules.&nbsp; The response was positive, and many people asked the same type of question: &nbsp; &ldquo;Can I set up my own internal repository for PowerShellGet?&rdquo; &nbsp; Many enterprise-oriented houses want the ability to create private module repositories (without sharing [&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":[216,217,274,344],"class_list":["post-1671","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","tag-module","tag-modules","tag-powershellget","tag-windows-management-framework"],"acf":[],"blog_post_summary":"<p>At TechEd, we announced and released an early version of PowerShellGet: a package manager for PowerShell modules.&nbsp; The response was positive, and many people asked the same type of question: &nbsp; &ldquo;Can I set up my own internal repository for PowerShellGet?&rdquo; &nbsp; Many enterprise-oriented houses want the ability to create private module repositories (without sharing [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/1671","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=1671"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/1671\/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=1671"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=1671"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=1671"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}