The problem may be you're running Windows PowerShell version 5.1.x. When you run pwsh -v
, you are actually invoking the PowerShell core executable from the 5.1 shell and it's returning its output (PowerShell 7.1.0) to the 5.1 shell and promptly exiting. That's why when you run $host you are getting 5.1.x
As such you obviously have 7.1 installed side by side with Windows PowerShell. Go to start Run type pwsh and hit enter. Now you'll be in a 7.1 shell, go ahead and load the module.
Note: you can also find PowerShell Core by searching from the start menu. It may be labeled "PowerShell 7 (x64). The executable is located at "C:Program FilesPowerShell7pwsh.exe"
Last note: The best way to check the PowerShell version in your Shell is via the $PSVersiontTable
automatic variable. The output will look like below:
Name Value
---- -----
PSVersion 5.1.14409.1018
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0, 5.0, 5.1.14409.1018}
BuildVersion 10.0.14409.1018
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
The output is a little different in PwSh 7.1:
Name Value
---- -----
PSVersion 7.1.0
PSEdition Core
GitCommitId 7.1.0
OS Microsoft Windows 6.3.9600
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0.}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
If you need version 7.1, you have it, then use it...
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…