Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-52421

Support PowerShell Core on Windows-Systems

XMLWordPrintable

      When the plugin detects "not Unix" it will try to start powershell.exe. On Windows Nano Server there is only PowerShell Core available and the executable name there is pwsh.exe. Creating a hardlink or symlink named powershell.exe that links to pwsh.exe does not work because when you run powershell.exe (the link) the process exits with the message:

      The managed DLL bound to this executable: 'pwsh.dll', did not match own name 'powershell.dll'.
      A fatal error was encountered. This executable was not bound to load a managed DLL.

      This makes it currently impossible to use PS Core on Nano Server.

      One simple solution would be to detect Nano Server and then just run pwsh.exe like on Unix systems.

      When running Windows Server Core this gets a little more complicated because you can have both the regular PS and PS Core side by side, so a decision must be made about the behavior in this case.
      The options are:

      • If pwsh.exe is in PATH then always prefer it over the regular one
      • If regular powershell.exe is available then always prefer it over PS Core

      The first option makes the most sense to me because having both PS versions is not likely to happen and if you have them running side by side that's probably because you want PS Core to be used (if you want regular PS then just don't install PS Core in the first place).

            Unassigned Unassigned
            stannieman Stan Wijckmans
            Votes:
            6 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: