{"id":1191,"date":"2015-05-05T09:51:00","date_gmt":"2015-05-05T09:51:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/powershell\/2015\/05\/05\/desired-state-configuration-resources-for-packagemanagement-providers\/"},"modified":"2019-02-18T12:38:39","modified_gmt":"2019-02-18T19:38:39","slug":"desired-state-configuration-resources-for-packagemanagement-providers","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/desired-state-configuration-resources-for-packagemanagement-providers\/","title":{"rendered":"Desired State Configuration Resources for PackageManagement Providers"},"content":{"rendered":"<p><strong>Introduction<\/strong><\/p>\n<p>You may have heard of, or even already used PackageManagement (aka OneGet). Recently, I was reading the OneGet blog and OneGet in GitHub, and decided to give it a try by installing the <a href=\"http:\/\/blogs.msdn.com\/b\/powershell\/archive\/2015\/04\/29\/windows-management-framework-5-0-preview-april-2015-is-now-available.aspx\">Windows Management Framework (WMF) 5.0 Preview April 2015<\/a>. I found that PackageManagement provides a consistent user experience by exposing the same set of PowerShell Cmdlets for different flavors of software installation technologies, such as PowerShell modules, NuGet packages, MSI, MSU, etc. It&rsquo;s indeed a unified package management framework. So I decided to write some Desired State Configuration (DSC) resources for some of the PackageManagement providers, which will hopefully make your life even easier.<\/p>\n<p><strong>Prerequisites<\/strong>:<\/p>\n<p>&bull; <a href=\"http:\/\/blogs.msdn.com\/b\/powershell\/archive\/2015\/04\/29\/windows-management-framework-5-0-preview-april-2015-is-now-available.aspx\">Windows Management Framework (WMF)&nbsp;5.0 Preview April 2015<\/a><\/p>\n<p><strong>PackageManagementProviderResource<\/strong><\/p>\n<p>As PackageManagement is a work-in-progress, I have started with the following two providers, since they are pretty stable already: PSModule and NuGet. I named the DSC module as PackageManagementProviderResource, containing the following DSC resources:<\/p>\n<ul>\n<li>PSModule is a DSC Resource that corresponds to the PSModule PackageManagement provider for managing PowerShell modules. It fetches modules from the <a href=\"https:\/\/powershellgallery.com\">PowerShell Gallery<\/a> repository.<\/li>\n<li>NuGetPackage is a DSC resource that corresponds to the NuGet PackageManagement provider for managing packages from NuGet repositories.<\/li>\n<li>PackageManagementSource is a DSC Resource that lets you register or unregister a package source on your computer.<\/li>\n<\/ul>\n<p>The source code for these DSC resources is available on the <a href=\"https:\/\/github.com\/PowerShell\/PackageManagementProviderResource\">PowerShell Github<\/a>. It&#8217;s also downloadable from the PowerShell Gallery using PowerShellGet (included in WMF 5.0 Preview):<\/p>\n<p><span style=\"font-family: terminal,monaco;font-size: small\">Install-Module -Repository PSGallery PackageManagementProviderResource<\/span><\/p>\n<p><strong>Samples<\/strong><\/p>\n<p><em>Sample 1<\/em> &ndash; Install a JQuery package from the NuGet source location<\/p>\n<p>In this&nbsp;DSC configuration, I used the PackageManagementSource and NuGetPackage DSC resources to install JQuery 2.0.1 from Nguet.org:<\/p>\n<p><a href=\"https:\/\/github.com\/PowerShell\/PackageManagementProviderResource\/blob\/master\/Examples\/Sample_NuGet_InstallPackage.ps1\">Sample_NuGet_InstallPackage.ps1<\/a><\/p>\n<p><em>Sample 2<\/em> &ndash; Install a PowerShell Module, &lsquo;xJea&rsquo; from the PowerShell gallery<\/p>\n<p>You may have noticed, unlike the above sample, that there is no package resource registration here. That is because the &lsquo;PSGallery&rsquo; was already registered when WMF 5.0 preview was installed. You can always run the Get-PackageSource cmdlet to find out what package sources have already been registered on your system.<\/p>\n<p><a href=\"https:\/\/github.com\/PowerShell\/PackageManagementProviderResource\/blob\/master\/Examples\/Sample_PSModule.ps1\">Sample_PSModule.ps1<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Hope you enjoy trying it out.<\/p>\n<p>Thanks<\/p>\n<p>Jianyun Tao<\/p>\n<p>PowerShell Team<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction You may have heard of, or even already used PackageManagement (aka OneGet). Recently, I was reading the OneGet blog and OneGet in GitHub, and decided to give it a try by installing the Windows Management Framework (WMF) 5.0 Preview April 2015. I found that PackageManagement provides a consistent user experience by exposing the same [&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":[150,216,227,235,236,248,281],"class_list":["post-1191","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","tag-dsc","tag-module","tag-oneget","tag-packagemanagement","tag-packagemanager","tag-powershell","tag-psmodule"],"acf":[],"blog_post_summary":"<p>Introduction You may have heard of, or even already used PackageManagement (aka OneGet). Recently, I was reading the OneGet blog and OneGet in GitHub, and decided to give it a try by installing the Windows Management Framework (WMF) 5.0 Preview April 2015. I found that PackageManagement provides a consistent user experience by exposing the same [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/1191","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=1191"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/1191\/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=1191"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=1191"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=1191"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}