Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagebash
titleShebang for PowerShell Job with Windows
@@setlocal enabledelayedexpansion & set f=%RANDOM%.ps1 & @@findstr/v "^@@f^@@[fs].*&" "%~f0"|pwsh > !f! & powershell.exe -&goto:eofNonInteractive -File !f! & set e=!errorlevel! & del /q !f! & exit !e!/b&

Explanation:

  • Credits for the Windows shebang replacement go to How to run a PowerShell script within a Windows batch file.
  • If you consider this shebang replacement somewhat cryptic then add it to JS7 - Script Includes which are easily referenced from a shell job, for example by using ##!include pwsh.
  • The PowerShell executable pwsh.exe is available starting from PowerShell 6.0. PowerShell releases 5.x use the executable powershell.exe which can be specified accordingly with the shebang.

...