GH-200 practice question 15 of 15
A development team has been using a Powershell script to compile and package their solution using existing tools on a Linux VM, which has been configured as a self-hosted runner. They would like to use the script as-is in an automated workflow. Which of the following should they do to invoke their script within a workflow step?
Full set: 100 questionsTo execute a PowerShell script on a Linux runner, the run step in the workflow must specify the shell to be used. PowerShell Core is cross-platform, and its executable on Linux is pwsh. By setting shell: pwsh, the workflow instructs the runner to use the PowerShell Core engine to interpret and execute the script commands provided in the run block. This allows the existing script to be used "as-is" on the configured Linux runner.
A. This contradicts the scenario, which specifies an existing Linux VM. The goal is to use the current setup, not create a new Windows one.
B. The powershell: keyword is not a valid top-level key for a workflow step. The correct syntax involves using shell: within a run step.
C. Converting the script to Bash (pwsh2bash) violates the requirement to use the script "as-is" without modification.
E. The actions/run-powershell action is generally for Windows runners and is less direct than using the built-in shell keyword for cross-platform execution.
1. GitHub Docs. (2023). Workflow syntax for GitHub Actions. Retrieved from https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjobidstepsshell. The documentation specifies pwsh as a built-in shell option for cross-platform PowerShell.
2. GitHub Docs. (2023). Choosing the shell that your commands are run in. Retrieved from https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#choosing-the-shell-that-your-commands-are-run-in. This section provides examples of using shell: pwsh for running PowerShell commands.
Keep practicing
Take the free GH-200 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other GH-200 practice questions
- Question 1Which action type should be used to bundle a series of run steps into a reusable custom a…
- Question 2As a developer, which workflow steps should you perform to publish an image to the GitHub…
- Question 3Where should workflow files be stored to be triggered by events in a repository?
- Question 5Which default environment variable specifies the branch or tag that triggered a workflow?
- Question 6As a developer, what is the safest way to reference an action to prevent modification of …
- Question 7Without the need to use additional infrastructure, what is the simplest and most maintain…
