{"id":2593,"date":"2018-09-06T20:18:06","date_gmt":"2018-09-06T20:18:06","guid":{"rendered":"http:\/\/microsoftgeek.com\/?p=2593"},"modified":"2018-09-06T20:23:59","modified_gmt":"2018-09-06T20:23:59","slug":"how-to-automate-software-package-installations-in-server-2016-via-powershell","status":"publish","type":"post","link":"https:\/\/microsoftgeek.com\/?p=2593","title":{"rendered":"How to Automate Software Package Installations in Server 2016 via PowerShell"},"content":{"rendered":"<p class=\"bold\">Here are some of the ways you can automate software package and modules installations in Server 2016, using some of the new package management cmdlets that come with PowerShell.<\/p>\n<p><span class=\"imgContent imgCenter\"><span class=\"imgWrapperOutter\"><span class=\"imgWrapperInner\"><img decoding=\"async\" title=\"\" src=\"http:\/\/media.bestofmicro.com\/K\/W\/598208\/gallery\/WinServer_Blu286_M_rgb_w_650.png\" alt=\"\" \/><\/span><\/span><\/span><\/p>\n<p>With the introduction of services like NuGet, Choclatey, PSGet and Package Manager, Windows finally has a great way of delivering software packages and modules directly from the internet or through an internal repository. Here are some of the ways you can automate software package and modules installations in Server 2016, using some of the new package management cmdlets that come with PowerShell.<\/p>\n<p>Let&#8217;s first see what commands are available to us. All of the package management commands are in the <span style=\"color: #ff00ff;\"><strong>PackageManagement<\/strong> <\/span>module.<\/p>\n<p><span class=\"imgContent imgCenter\"><span class=\"imgWrapperOutter\"><span class=\"imgWrapperInner\"><img decoding=\"async\" title=\"\" src=\"http:\/\/media.bestofmicro.com\/4\/1\/598897\/gallery\/howto-automate-installs-powershell-1_w_755.jpg\" alt=\"\" \/><\/span><\/span><\/span><\/p>\n<p>It looks like we have all the necessary cmdlets to manage software on my Server 2016 machine. I&#8217;m currently building a Server 2016 machine for some testing purposes and need a few modules to do some further configuration.<\/p>\n<p>I&#8217;d like to get the AzureRm PowerShell module installed. Rather than going out on\u00a0Github, download all the files and manually placing them in the right folder, let&#8217;s use Install-Package to quickly do this directly from PowerShell.<\/p>\n<p>First, I&#8217;ll need to find the module in one of the currently configured providers. You can see a list of configured providers by using the <span style=\"color: #ff00ff;\"><strong>Get-PackageProvider<\/strong><\/span> cmdlet.<\/p>\n<p><span class=\"imgContent imgCenter\"><span class=\"imgWrapperOutter\"><span class=\"imgWrapperInner\"><img decoding=\"async\" title=\"\" src=\"http:\/\/media.bestofmicro.com\/4\/2\/598898\/gallery\/howto-automate-installs-powershell-2_w_755.jpg\" alt=\"\" \/><\/span><\/span><\/span><\/p>\n<p>However, I don&#8217;t need to know this right off the bat. I can use <span style=\"color: #ff00ff;\"><strong>Find-Package<\/strong><\/span> to search through all providers automatically in search of a module or software package that I&#8217;m looking for; in this case, the AzureRm module.<\/p>\n<p>I&#8217;m going to run <span style=\"color: #ff00ff;\"><strong>Find-Package<\/strong><\/span> and provide it the name of the module I&#8217;m after. You can see that it found a match in the PowerShell Gallery.<\/p>\n<p><span class=\"imgContent imgCenter\"><span class=\"imgWrapperOutter\"><span class=\"imgWrapperInner\"><img decoding=\"async\" title=\"\" src=\"http:\/\/media.bestofmicro.com\/4\/8\/598904\/gallery\/howto-automate-installs-powershell-3_w_755.jpg\" alt=\"\" \/><\/span><\/span><\/span><\/p>\n<p>To install this, I pipe that result directly to <strong><span style=\"color: #ff00ff;\">Install-Package<\/span><\/strong>, which will immediately begin installing the module, after I confirm that I trust the PowerShell Gallery as a source.<\/p>\n<p>However, maybe I just want to download it to inspect it before actually installing the module. I could do this by using the<strong><span style=\"color: #ff00ff;\"> Save-Package<\/span> <\/strong>command and specify the folder path where I&#8217;d like to save the package to.<\/p>\n<p><span style=\"color: #ff00ff;\"><strong>Find-Package \u2013Name AzureRm | Save-Package \u2013Path C:Downloads<\/strong><\/span><\/p>\n<p>&nbsp;<\/p>\n<p>But what if I need a piece of software rather than a module? In that case, Chocolatey is the way to go. Chocaletey is a repository of thousands of pieces of software packaged up and ready to be automated. However, installing packages from Chocolatey don&#8217;t come by default in Server 2016. We&#8217;ll need to add this as a provider first. To do this, I&#8217;ll first need to see if it&#8217;s available as a provider.<\/p>\n<p><span class=\"imgContent imgCenter\"><span class=\"imgWrapperOutter\"><span class=\"imgWrapperInner\"><img decoding=\"async\" title=\"\" src=\"http:\/\/media.bestofmicro.com\/4\/4\/598900\/gallery\/howto-automate-installs-powershell-4_w_755.jpg\" alt=\"\" \/><\/span><\/span><\/span><\/p>\n<p>Once I confirm it&#8217;s available, I can then download it by using <span style=\"color: #ff00ff;\"><strong>Install-PackageProvider<\/strong><\/span><\/p>\n<p><span class=\"imgContent imgCenter\"><span class=\"imgWrapperOutter\"><span class=\"imgWrapperInner\"><img decoding=\"async\" title=\"\" src=\"http:\/\/media.bestofmicro.com\/4\/3\/598899\/gallery\/howto-automate-installs-powershell-5_w_755.jpg\" alt=\"\" \/><\/span><\/span><\/span><\/p>\n<p>Next, I&#8217;ll need to import it so that I can use it.<\/p>\n<p><span class=\"imgContent imgCenter\"><span class=\"imgWrapperOutter\"><span class=\"imgWrapperInner\"><img decoding=\"async\" title=\"\" src=\"http:\/\/media.bestofmicro.com\/4\/0\/598896\/gallery\/howto-automate-installs-powershell-6_w_755.jpg\" alt=\"\" \/><\/span><\/span><\/span><\/p>\n<p>And finally, confirm that it&#8217;s now an available provider.<\/p>\n<p><span class=\"imgContent imgCenter\"><span class=\"imgWrapperOutter\"><span class=\"imgWrapperInner\"><img decoding=\"async\" title=\"\" src=\"http:\/\/media.bestofmicro.com\/4\/7\/598903\/gallery\/howto-automate-installs-powershell-7_w_755.jpg\" alt=\"\" \/><\/span><\/span><\/span><\/p>\n<p>Now I can install any software in the Chocolatey repository. Let&#8217;s install 7zip as an example. To do that, I&#8217;ll run <span style=\"color: #ff00ff;\"><strong>Find-Package<\/strong><\/span> and see if a package called 7Zip exists.<\/p>\n<p><span class=\"imgContent imgCenter\"><span class=\"imgWrapperOutter\"><span class=\"imgWrapperInner\"><img decoding=\"async\" title=\"\" src=\"http:\/\/media.bestofmicro.com\/4\/5\/598901\/gallery\/howto-automate-installs-powershell-8_w_755.jpg\" alt=\"\" \/><\/span><\/span><\/span><\/p>\n<p>I want the entire 7Zip package, so I&#8217;ll just download and install the top option. You&#8217;ll notice when the install starts, Chocolatey automatically downloads and installs any dependent packages as well. Once I found the package on the Chocolatey repository I piped that to <span style=\"color: #ff00ff;\"><strong>Install-Package<\/strong><\/span>.\u00a0 It then noticed that a couple dependent packages were needed and installed them as well.<\/p>\n<p><span class=\"imgContent imgCenter\"><span class=\"imgWrapperOutter\"><span class=\"imgWrapperInner\"><img decoding=\"async\" title=\"\" src=\"http:\/\/media.bestofmicro.com\/4\/6\/598902\/gallery\/howto-automate-installs-powershell-9_w_755.jpg\" alt=\"\" \/><\/span><\/span><\/span><\/p>\n<p>That was a lot easier than going out to the Internet, searching for a download link somewhere and installing it that way.<br \/>\nYou&#8217;ve seen Windows now has a powerful package management system. Whether you need to download PowerShell scripts or modules from the PowerShell Gallery or need to automate software installations, both can be done via the package management cmdlets you can find on Server 2016.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here are some of the ways you can automate software package and modules installations in Server 2016, using some of the new package management cmdlets that come with PowerShell. With the introduction of services like NuGet, Choclatey, PSGet and Package Manager, Windows finally has a great way of delivering software packages and modules directly from [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[59,63],"tags":[],"class_list":["post-2593","post","type-post","status-publish","format-standard","hentry","category-powershell","category-server-2016-2016"],"_links":{"self":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts\/2593","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2593"}],"version-history":[{"count":6,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts\/2593\/revisions"}],"predecessor-version":[{"id":2599,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts\/2593\/revisions\/2599"}],"wp:attachment":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2593"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2593"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2593"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}