I co-maintain the Chocolatey package deal for PowerShell. With the latest launch of PowerShell 5.1, the Chocolate packaging is ready to deal with yet another difficult, however doubtlessly widespread, deployment situation.
Microsoft is transferring quick to retire model 5.0 by June of 2017 – together with eradicating the downloads for five.0 – a definite encouragement to judge and undertake 5.1 shortly.
Lets speak about this problem in addition to a short abstract of another difficult deployment eventualities that had been already dealt with by the Chocolatey Package deal.
Due to the Microsoft PowerShell groups forthcoming publishing of the 5.1 launch limitations – none of this info needed to be found the arduous means by all these making an attempt to deploy 5.1 – these are identified points highlighed in launch notes and downloads and Microsoft has supplied a PowerShell helper script to use 5.1 within the trickiest eventualities.
Utilizing Home windows Replace
Microsoft not too long ago revealed PowerShell 5.1 for Server 2012 R2 and Home windows 8.1 to the Home windows Replace Catalog – if your organization actively manages Home windows updates that is possible the smoothest option to 5.1.
PowerShell 5.1 Deployment Problem #1
The primary problem is that PowerShell 5.1 requires .NET 4.5.2 – but it surely doesn’t set up it nor refuse to put in if it isn’t current. I’m an advocate of this conservative method to upgrading .NET runtimes. I’ve come throughout many functions which are fairly delicate to the model of .NET used and I actually don’t need to be the admin that despatched a whole fleet of manufacturing cloud servers to their early demise as a result of I “innocently” deployed PowerShell. And sure, whereas it’s true that each one adjustments must be examined earlier than deploying – many occasions the faults present up in areas that aren’t at present a part of even probably the most thorough take a look at plans or take a look at automation.
In contrast to immediately deploying the .MSU, the Chocolatey package deal will refuse to put in if the .NET model is just not sufficent for set up – this alerts you to the problem instantly.
PowerShell 4 and 5.0 upgrades each had related habits – the Chocolatey package deal will guarantee you might be conscious that your .NET model is inadequate for full PowerShell performance or for the improve to even succeed. In some instances the improve goes wonderful, however the model of PowerShell doesn’t change after reboot on account of missing the right .NET model.
PowerShell 5.1 Deployment Problem #2
The second problem is extra particular. It’s a excellent news, unhealthy information story. The excellent news is now you can set up PowerShell 5.1 with out first putting in PowerShell 4.0 (WMF 4 is a requirement for putting in WMF 5.0) on Home windows 7 / Server 2008 R2 (Home windows Model 6.1) machines- superior and hats off to the PowerShell group for serving to with this backlevel downside to this point down the street – they’re actually listening to their customers.
The unhealthy information is that in the event you occur to have put in PowerShell / WMF 3 on these machines (and lots of, many people did), then your PSModulePath will be misplaced in the course of the improve. What’s the massive deal you ask? Nicely in case your PSModulePath was by no means modified by putting in customized modules or administrative instruments which have their PowerShell modules in a customized folder – you then would don’t have any issues merely ensuring the default paths are in PSModulePath. Nonetheless, PowerShell has such broad utilization throughout all Home windows machines that it’s most certainly going to interrupt one thing by wiping out any customizations to PSModulePath as many optionally available software program installs will add to the trail.
The brand new PowerShell package deal doesn’t appear to have the ability to deal with this problem – my guess is as a result of the elimination occurs as a part of the code within the WMF 3 package deal’s self-removal code. I’ve examined and decided that the motion occurs AFTER the required reboot – making it tough to get one’s palms on a fixup.
The Powershell Chocolatey Package deal for five.1 detects when you find yourself placing 5.1 over high of three.0 and saves the trail customizations apart and queues them up for re-addition after the reboot. The tactic for scheduling this reboot process on a headless system was the subject of [this Mission Impossible Code post].(https://missionimpossiblecode.com/submit/continue-your-automation-to-run-once-after-restarting-a-headless-windows-system/)
PowerShell 5.1 Deployment Problem #3
One other automation problem lurks as effectively – that is the truth that it is rather simple to mess up path surroundings variables in the event you aren’t cautious. Most notably it is rather unhealthy apply to learn the present processes “PSModulePath”, replace it and write it again to the Machine degree surroundings variable. The trail updating code within the PowerShell 5.1 package deal was lined on this Mission Unattainable Code submit – together with precise working code. Amongst different issues, this code ensures that you don’t unintentionally increase surroundings variables contained in your path to their static values.
All elements of this problem are dealt with by the Chocolatey Package deal for PowerShell 5.1 – on the time of this writing the package deal has been downloaded 142,000 occasions.
If you happen to’ve been listening to the thrill about Chocolatey and need to get began, you would possibly need to watch my PluralSight coures titled [Chocolatey NuGet Essentials for Automation Pros].(https://app.pluralsight.com/participant?course=chocolatey-nuget-automation-pros&writer=darwin-sanoy&title=chocolatey-nuget-automation-pros-m0&clip=0)
You could find this package deal at https://chocolatey.org/packages/powershell.
Steal My PowerShell Code / This Code In Manufacturing
If you happen to at present can’t leverage PowerShell or desire to roll this difficult replace your self, you may steal the code from the Chocolatey Package deal – listed below are the related traces: https://gitlab.com/DarwinJS/ChocoPackages/-/blob/grasp/PowerShell/v5.1/instruments/ChocolateyInstall.ps1#L106-174