Windows is using PowerShell Core instead of PowerShell as documented

Hi!

I have another thing that confuses me: It seems Actions uses PowerShell Core and not the default Desktop PowerShell.

My workflow action:

name: Build (Windows)

on: [deployment]

jobs:
  build-win:

    runs-on: windows-latest

    if: github.event.deployment.environment == 'win'

    steps:
    - name: Checkout
      uses: actions/checkout@v1

    - name: Build
      run: $PSVersionTable.PSVersion

The output:

Major Minor Patch PreReleaseLabel BuildLabel
----- ----- ----- --------------- ----------
6 2 3

As far as i know this refers to PoweShell 6, which is PowerShell Core.

The default PowerShell on Windows Server 2019 is PowerShell 5.1.

The documentation says: 

This is the default shell used on Windows. The Desktop PowerShell. GitHub appends the extension .ps1 to your script name.

This seems like a bug.

Regards,

Michael

Hi,

Thank you for taking time to report this!

Powershell 6.2.3 is the correct version which will be invoked, please refer to my screenshot below.

The twitter link: https://twitter.com/GitHubHelp/status/1186648849995177985

I also checked the github runner env, only powershell 6.2.3 is installed.

https://help.github.com/en/github/automating-your-workflow-with-github-actions/software-in-virtual-environments-for-github-actions

 Thanks!

Thanks for your anwser!

Am i correct, that the output for using shell: powerstell and shell: pwsh is the same on Windows?

If shell: powershell also calls Powershell Core it would be safe to remove the shell: powershell completely and just make shell: pwsh the default.

AFAIK Poweshell 5.x is installed by default on Windows Server 2019. Therefore the virtual env docs might not have reflected this properly?

Anyway it seems confusing to have two shell options which call the same PowerShell. The docs should clearly state why this choice has been made and when i should use shell: powershell and when to use shell: pwsh. At the moment i am not confident to make a proper choice.

(When reading the docs it seems that the difference should have been PowerShell Core vs PowerShell Desktop. If this difference was purposely then this is indeed a bug and shell: powershell should properly call the shipped PowerShell which is 5.x)

Regards,

Michael

It did some more research on this. I have a stock Windows Server 2019 installation.

Running in the Desktop PowerShell:

PS C:\Users\Administrator> $PSVersionTable

Name Value
---- -----
PSVersion 5.1.17763.592
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.592
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Running in the additionally installed PowerShell Core:

PS C:\Users\Administrator\build\win> $PSVersionTable

Name Value
---- -----
PSVersion 6.2.3
PSEdition Core
GitCommitId 6.2.3
OS Microsoft Windows 10.0.17763
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

The documentation states the following: (https://help.github.com/en/github/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions)

This is the default shell used on Windows. The Desktop PowerShell. GitHub appends the extension .ps1 to your script name.

The Desktiop edition is clearly the one with version 5.1.x. Therefore this seems like either a totaly wrong documentation (and as suggested a redundant shell: powershell option) or a bug that the wrong PowerShell is called.

Regards,

Michael

It is definitly a bug. 

Using a custom shell as specified in the documentation will properly run the stock Desktop Powershell.

My modified workflow:

- name: Build
      shell: powershell -command "& '{0}'"
      run: |
        cd win
        .\build.ps1 -BuildConfiguration Release

Here is the output

Using the default shell will run the PowerShell Core.

Regards,

Michael

Thanks for your feedback! There are two parameters here: pwsh / powershell,

for “shell: pwsh”: powershell core(6.2.3) will be invoked.

for “shell: powershell”: desktop powershell(5.1) will be invoked.

If you didn’t point out the shell parameter, powershell core will be invoked as it’s default.

As offical doc says:

Users can always opt out by not using the built-in shell, and providing a custom shell option like: pwsh -File {0}, or powershell -Command “& ‘{0}’”, depending on need.

Thanks.

1 Like

Thanks for the clarification. So it is just a simple documentation issue, which states that PowerShell Desktop is the default instead of PowerShell Core.

Regards,

Michael

I have fallen for this one again. Could you fix the documentation and correctly state that Powershell Core is the default shell on Windows?