This GitHub Actions blog post will show how to run a PowerShell script on Windows and Linux runners.
With GitHub Actions Linux and Windows runners, we can run PowerShell 7 scripts natively.
In the following two examples, We run a PowerShell script that is available inside the repository.
The code below shows how to run a PowerShell on a Windows-based runner machine.
Note: The script is running on Windows Server 2019. For Windows Server 2016, change run-on to windows-2016.
name: How to use a Windows Runner on GitHub Actions on: push jobs: build: runs-on: windows-2019 steps: - name: Check out repo uses: actions/checkout@v2 - run: | ./myscript.ps1
To run the same script on a Linux based runner (Ubuntu), I will use the following code.
name: Run PowerShell Scripts on: push jobs: build: runs-on: ubuntu-latest steps: - name: Check out repo uses: actions/checkout@v2 - run: | ./myscript.ps1 shell: pwsh