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.
Related
I'm currently trying to remote to multiple servers that are on PowerShell 4.0 whereas the local computer currently runs on 5.0+. I am attempting to query servers that are Server 2016 for the Local Administrator group, but will fail for servers that are on 2012. Which upon researching the error messages for cmdlets from Microsoft.Powershell.LocalAccounts indicates that the modules don't exist for 2012.
Rather than updating the PowerShell version, or installing the modules to each server, I wondering if it's possible to execute cmdlets from the local 2016 into remote sessions of the 2012 servers.
Technically, yes, you could copy modules from the local server to one of the module directories on the remote server's $env:PSModulePath and import them in the remote session, but as #mklement0 stated there is no guarantee current modules will work with PowerShell 4.0, let alone Server 2012.
That said, Microsoft.PowerShell.LocalAccounts is a module provided by PowerShell 5.1, not the OS, and the features should still work on 2012. However, I don't have a 2012 instance I can test with. But you may be able to get your task done by upgrading your servers' PowerShell version to PowerShell 5.1 (Windows Management Framework 5.1) to leverage the additional features and built-in modules this version brings. But any modules that are shipped with later Windows versions and not PowerShell itself will remain unavailable.
$localAdminUsers = net localgroup administrators
After some talking with a colleague, I realized I had overcomplicated my script, when I could have used the command prompt. From there, I parse the string for the users I was looking for.
Thank you for your responses.
So I've just read a lengthy explanation of the difference between PowerShell and PowerShell Core. Basically, the latter is the new name for all future versions of PowerShell, and it's now open source and cross-platform.
Alright. Good. But why does it have to be installed on Windows? Wouldn't the point be that it's already on Windows, but then you can also install it on Linux/macOS and use it the same way as on Windows?
Why is it an "installation" even on Windows? That part makes no sense to me. And it can't be explained by "it's just released", because it's apparently been several years already...
Powershell Core is the new Universal Powershell.
Windows Comes with "Windows Powershell" which was the predecessor to Powershell core and only runs on windows, and uses methods that are windows .net specific, instead of using the portable.net methods.
Powershell Core is being actively developed and enhanced, and is able to be run on Windows and Linux systems, but does not contain the Windows-specific methods as it is intended to be cross-platform, which leads to some incompatibilities.
Rather than continue to build and maintain separate flavors of Powershell in perpetuity, the Windows Powershell 5.1 functions will eventually fold into PowerShell core at some point in the future (possibly as early as version 7.0), and deprecated methods will need to be re-written to use the universal functions.
Last I read on this Redmond had predicted that Powershell Core 7.0 will essentially usurp the needs for Powershell 5.1 on Windows and will start being the pre-installed version of Powershell in Windows at some point thereafter. (So Probably Windows 2022 for Server folks)
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
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.
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