How to upgrade PowerShell version from 2.0 to 3.0 - powershell

The OS that I am using is Windows 7, and the PowerShell version that is installed here is 2.0. Is it possible for me to upgrade it to version 3.0 or 4.0?
Because there are cmdlets that version 2.0 can't recognize.

Download and install from http://www.microsoft.com/en-us/download/details.aspx?id=34595. You need Windows 7 SP1 though.
It's worth keeping in mind that PowerShell 3 on Windows 7 does not have all the cmdlets as PowerShell 3 on Windows 8. So you may still encounter cmdlets that are not present on your system.

The latest PowerShell version as of Sept 2015 is PowerShell 4.0. It's bundled with Windows Management Framework 4.0.
Here's the download page for PowerShelll 4.0 for all versions of Windows.
For Windows 7, there are 2 links on that page, 1 for x64 and 1 for x86.

Just run this in a console.
#powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin
cinst powershell
It installs the latest version using a Chocolatey repository.
Originally I was using command cinst powershell 3.0.20121027, but it looks like it later stopped working. Since this question is related to PowerShell 3.0 this was the right way. At this moment (June 26, 2014) cinst powershell refers to version 3.0 of PowerShell, and that may change in future.
See the Chocolatey PowerShell package page for details on what version will be installed.

Install Chocolatey
Run the following commands in CMD
choco install powershell
choco upgrade powershell

As of today, Windows PowerShell 5.1 is the latest version. It can be installed as part of Windows Management Framework 5.1. It was released in January 2017.
Quoting from the official Microsoft download page here.
Some of the new and updated features in this release include:
Constrained file copying to/from JEA endpoints
JEA support for Group Managed Service Accounts and Conditional Access Policies
PowerShell console support for VT100 and redirecting stdin with interactive input
Support for catalog signed modules in PowerShell Get
Specifying which module version to load in a script
Package Management cmdlet support for proxy servers
PowerShellGet cmdlet support for proxy servers
Improvements in PowerShell Script Debugging
Improvements in Desired State Configuration (DSC)
Improved PowerShell usage auditing using Transcription and Logging
New and updated cmdlets based on community feedback

The latest PowerShell version as of Aug 2016 is PowerShell 5.1. It's bundled with Windows Management Framework 5.1.
Here's the download page for PowerShell 5.1 for all versions of Windows, including Windows 7 x64 and x86.
It is worth noting that PowerShell 5.1 is the first version available in two editions of "Desktop" and "Core". Powershell Core 6.x is cross-platform, its latest version for Jan 2019 is 6.1.2. It also works on Windows 7 SP1.

do use the links above. If you run into error "This update is not applicable to your computer. " then make sure you are in fact using the right file for your os. for example i tried running windows 2012 server from that link on windows 7 service pack 1 and I got the above error so be sure to use the right zip. If you don't know which os you have then go to start and system and it should pop right up This should be self explanatory but

Related

PowerShell 7 use Chocolatey as PackageManager

PowerShell 5 and 7 are different still when it comes to PackageManagers.
Chocolatey seems not to be 'integrated' yet and I cannot use Chocolatey in PowerShell 7 as I do in PowerShell 5.
I have installed chocolatey the way their site says but this lets me use chocolatey with starting my command with choco.
How can I configure Chocolatey in PowerShell 7 so that I can use it like I do in PowerShell 5.
Find-Package -ProviderName Chocolatey -Name <packagename>
As of PowerShell [Core] 7, it looks like you cannot use Chocolatey as a provider for PowerShell's PackageManagement module, which means that you cannot discover or install Chocolatey packages with Find-Package and Install-Package.
However, direct use of Chocolatey via its CLI, choco.exe, works just fine in PowerShell [Core] (an *.exe file runs as long as its runtime is present on the system, which needn't be the same runtime as PowerShell's).
Read on for background information:
It looks like implementing a PackageManagement provider would require access to Chocolatey APIs in a manner that supports only .NET Framework (FullCLR), not also .NET Core (on which PowerShell [Core] is built)[1]; a quote from the read-me of Chocolatier, a community-provided alternative to the never-released prototype of the official provider:
Currently, Chocolatier works on Full CLR. It is not supported on CoreClr (...). The primary reason is that the current version of choco.exe does not seem to support CoreClr yet.
As for use on Windows PowerShell:
The official - Windows PowerShell-only - prototype for the Chocolatey PackageManagement provider has to date, many years later, not been implemented; here's what the docs say, retrieved on 13 Apr 2020 (emphasis added):
Chocolatey has a prototype provider for the built-in package manager on Windows 10/Windows Server 2016 that was created by Microsoft awhile back. It is not fully functional and it may have security issues. If you want to use Chocolatey with PackageManagement, we recommend using ChocolateyGet, which is a nice bridge until an official one is implemented. No ETA has been defined.
Note:
The aforementioned Chocolatier, which builds on ChocolateyGet, seems to be the more actively maintained project as of this writing.
There is a fairly recent pending PR by a community member for the official prototype, but it hasn't received any attention; also, it isn't complete yet either; for the full backstory, see this GitHub issue.
[1] If you know details, do let us know.
I manage the Chocolatier community project that mklement0 mentions in their (excellent) answer.
You're correct that PackageManagement works a bit differently under PowerShell 7, and on its initial release, many PackageManagement providers didn't work at all. The defect in PowerShell 7 was fixed in their 7.0.1 release, though there is still some work for PackageManagement provider maintainers to integrate with PowerShell 7.
As of May 2020, the Chocolatier provider will work with both PowerShell 5.1 and PowerShell 7, even though Chocolatey is written in the older .NET Framework that isn't compatible with PowerShell 7. When the provider runs under PowerShell 7, it will construct and run the Chocolatey CLI commands for you (ex: choco install firefox), bypassing the .NET compatibility problem.
If you're still interested in using PackageManagement to interact with Chocolatey, I'd recommend giving Chocolatier a try. I've iterated on it through both personal and professional use (works with private repositories and Desired State Configuration), and though I'm a bit biased, am pretty happy with it.

PowerGUI script editor does not recognize the updated powershell version?

I have ARS Shell 1.7.0 installed as part of ARS 6.9 & my MS (windows) powershell version is 4 (obtained by $PSVersionTable.PSVersion, screenshot below)
however when I do the same within the PowerGUI I get version as 2? This has started after i upgraded by shell version to 1.7 from 1.6.9 (PowerGUI worked fine with 1.6.9). I have no clue why is this happening & due to this I'm unable to use any quest cmdlets within the PowerGUI editor which make debugging my scripts an impossible task!
Screenshot from PowerGUI :
I get below error when i try to load ActiveRolesManagementShell from PowerGUI:
UPDATE: tried running Powershell (x86) but still the result is same, can anyone please let me know where in the world is PowerGUI picking up version 2 ?
Updated the PowerGUI Script editor to version to 3.8 & it resolved the issue. PowerGUI now recognizes v4
People using ver 3.2 should make a note of it.
I think the issue might be due to a change in ARS 1.7.0 that is forcing the PS2 engine to be required, per this:
Windows PowerShell 4.0 and Windows PowerShell 3.0 are designed to be
backwards compatible with Windows PowerShell 2.0. Cmdlets, providers,
snap-ins, modules, and scripts written for Windows PowerShell 2.0 run
unchanged in Windows PowerShell 4.0 and Windows PowerShell 3.0.
However, due to a change in the runtime activation policy in Microsoft
.NET Framework 4, Windows PowerShell host programs that were written
for Windows PowerShell 2.0 and compiled with Common Language Runtime
(CLR) 2.0 cannot run without modification in Windows PowerShell 3.0 or
Windows PowerShell 4.0, which are compiled with CLR 4.0. The Windows
PowerShell 2.0 Engine is intended to be used only when an existing
script or host program cannot run because it is incompatible with
Windows PowerShell 4.0, Windows PowerShell 3.0, or Microsoft .NET
Framework 4. Such cases are expected to be rare.
Many programs that require the Windows PowerShell 2.0 Engine start it
automatically. These instructions are included for the rare situations
in which you need to start the engine manually.
https://msdn.microsoft.com/en-us/powershell/scripting/setup/starting-the-windows-powershell-2.0-engine

Powershell: Upgrading from v.1 to v.3

I have a machine with windows server 2008 and has Powershell v.1, I have a few cron jobs executing a few powershell scripts that run on v.1.
My question is: Will any scripts break if I upgrade to version v.3 or is there version v.4 also?
PowerShell 4.0 exists, but it's not supported on Windows Server 2008 (only R2).
Your scripts should work fine, as PS is backwards compatible, ex. PS 1.0 used Snapins instead of modules, and Snapins is still supported in PS 3.0 / 4.0. But as with any upgrade, you need to test it yourself. PS 3.0 + runs on .Net Framework 4, where some APIs may behave differently then they did in earlier versions.

Do all script users need Powershell installed?

Looking to use Powershell for writing some scripts. The concern is, do all users of the script need Powershell installed on their computer in order to have the script execute properly? Is the behavior different for Windows 7 vs. XP vs. 2k etc? I understand powershell is included in 8, so that's not a concern.
PowerShell is also included in Windows 7. PowerShell might be included in XP not sure on that. I'm pretty sure 2k does not have PowerShell. Yes, if you want to run a PowerShell script you will need to have PowerShell installed. Just like you would need Python installed if you want to run a Python script.
I know that Win 7 comes with PS version 2.0 by default. Not sure on XP. The current version is PS is 3.0 it comes with the Windows Management Framework (WMF) 3.0.
During December 2012 Microsoft had the WMF 3.0 deployed as an update but recalled it a couple of weeks later because there was some compatibly errors with other stuff.
I'm using PS 3.0 and updating all my computers to PS 3.0. PS add new stuff that I want to learn.

How to Run PowerShell v3 console in v2 mode

In recent updates of Windows Server 2008 R2, they are pushing Windows PowerShell V3.0 also along with that.
But, our scripts are built and tested in V2 till now.
How can I run PowerShell V3 Console in V2 mode.?
Note: I tried "-Version 2" while starting the PowerShell.exe. But it is not working.
In what way is powershell.exe -version 2 not working? This is how you run v2 when v3 is installed.
BTW, make sure that the PowerShell 2.0 engine is installed. Check Windows Features: