Discrepancy in Powershell version reporting.
-
If I run this in PS
Get-Host | Select-Object Version
It responds with:
PS C:\Windows\system32> Get-Host | Select-Object Version Version ------- 3.0 PS C:\Windows\system32>
Yet when I run
choco install powershell -y
I get
C:\>choco install powershell -y Chocolatey v0.10.15 Installing the following packages: powershell By installing you accept licenses for the packages. PowerShell v5.1.14409.20180811 already installed. Use --force to reinstall, specify a version to install, or try upgrade. Chocolatey installed 0/1 packages. See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log). Warnings: - powershell - PowerShell v5.1.14409.20180811 already installed. Use --force to reinstall, specify a version to install, or try upgrade. C:\>
Any suggestions?
-
That doesn't look like the proper way to get the Powershell version via Powershell to me
-
@flaxking said in Discrepancy in Powershell version reporting.:
That doesn't look like the proper way to get the Powershell version via Powershell to me
I can use this
PS C:\Users\administrator.HT> $PSVersionTable.PSVersion Major Minor Build Revision ----- ----- ----- -------- 3 0 -1 -1 PS C:\Users\administrator.HT>
or this
PS C:\Users\administrator.HT> get-host Name : ConsoleHost Version : 3.0 InstanceId : 2137d8b2-7228-4849-9304-0120e4ea35bc UI : System.Management.Automation.Internal.Host.InternalHostUserInterface CurrentCulture : en-US CurrentUICulture : en-US PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy IsRunspacePushed : False Runspace : System.Management.Automation.Runspaces.LocalRunspace PS C:\Users\administrator.HT>
or this
PS C:\Users\administrator.HT> (Get-Host).Version Major Minor Build Revision ----- ----- ----- -------- 3 0 -1 -1 PS C:\Users\administrator.HT>
or this
PS C:\Users\administrator.HT> (Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine -Name 'Powe rShellVersion').PowerShellVersion 3.0 PS C:\Users\administrator.HT>
or this
PS C:\Users\administrator.HT> reg query HKLM\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine /v PowerShellVersion HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine PowerShellVersion REG_SZ 3.0 PS C:\Users\administrator.HT>
They all return the same version.
-
@flaxking said in Discrepancy in Powershell version reporting.:
That doesn't look like the proper way to get the Powershell version via Powershell to me
It's right, Version is the object that Get-Host uses to list the running PS version.
-
@JasGot Choco is returning the version the Choco has installed, it is not returning the version that is selected by default when you execute the PowerShell command. I guarantee you have multiple versions installed side by side.
-
@scottalanmiller said in Discrepancy in Powershell version reporting.:
@JasGot Choco is returning the version the Choco has installed, it is not returning the version that is selected by default when you execute the PowerShell command. I guarantee you have multiple versions installed side by side.
C:\Users\administrator.HT>powershell -Version 5 Cannot start Windows PowerShell version 5 because it is not installed. C:\Users\administrator.HT>
-
-
Might be as simple as PS5 not being in the normal path. Check its absolute path.
-
@scottalanmiller said in Discrepancy in Powershell version reporting.:
Might be as simple as PS5 not being in the normal path. Check its absolute path.
That would have been too easy
There is only one powershell installation and it is at:
C:\Windows\System32\WindowsPowerShell\v1.0\Which is right where it belongs. I'm running the stand alone gui installer now to see if that works.
-
Do you have WMF 5.1 installed?
-
@black3dynamite said in Discrepancy in Powershell version reporting.:
Do you have WMF 5.1 installed?
That's the gui installer I'm going to install to see if it works. If it does, I should then be able to install it again with -force, or use Chocolaty with the upgrade option and see it go smoothly.
-
what version of windows are you on?
-
You need to reboot however so it shows the correct powershell version after the install. Did you do that?
-
@Dashrender said in Discrepancy in Powershell version reporting.:
what version of windows are you on?
Server 2012
-
@dbeato said in Discrepancy in Powershell version reporting.:
You need to reboot however so it shows the correct powershell version after the install. Did you do that?
Sadly. Several times.
Busy weekend. I'll have to get back to this next week.
The ignition for this was the desire to start using Chocolaty. It has been one obstacle after another to get it off the ground. And know this, my goal is to get Powershell updated, .Net updated, and Chocolaty installed all from scripts within a backstage connection through SC.
So there are tons of scenarios that have to be worked out, and handled, all through scripting. :anguished_face:
-
@JasGot chocolatey is the easy one.
-
What version of .net is installed on the server?
I'm failing to remember which version of Powershell had a hard but silent requirement for a particular version of .net.
If memory serves it would install successfully (no errors) but would actually fail to install if the correct ver of .net was not already installed.