Skip to content

Skip PSResourceGet install on Windows in build-validation workflow#1813

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-build-validation-job
Draft

Skip PSResourceGet install on Windows in build-validation workflow#1813
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-build-validation-job

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 1, 2026

📑 Description

build-validation was failing on the Windows runner because Install-Module Microsoft.PowerShell.PSResourceGet terminated the PowerShell process (-1073741502) before try/catch could handle it. This change makes that install non-Windows-only while leaving all other dependency installs unchanged.

  • Root cause containment
    • Gate Microsoft.PowerShell.PSResourceGet installation behind a Windows OS check.
  • Behavior preserved
    • Linux/macOS continue attempting the install exactly as before (same command, same try/catch).
    • Windows still installs all other modules in the step.
  • Scope
    • Single-file, targeted workflow update in .github/workflows/build-validation.yaml.
if ($env:RUNNER_OS -ne 'Windows') {
  try {
    Install-Module Microsoft.PowerShell.PSResourceGet -Force -SkipPublisherCheck -Scope CurrentUser -AllowClobber -ErrorAction Stop
  }
  catch {
    Write-Warning "Unable to install Microsoft.PowerShell.PSResourceGet: $($_.Exception.Message)"
  }
}

✅ Checks

  • My pull request adheres to the code style of this project.
  • My code requires changes to the documentation.
  • I have updated the documentation as required.
  • The build and unit tests pass after running /powershell/tests/pester.ps1 locally.

ℹ️ Additional Information

No functional changes outside the Install PowerShell dependencies step logic for Microsoft.PowerShell.PSResourceGet.


How to Contribute

🏗️ Read our full contributing guide for the Maester project.
🧪 We also have additional instructions and a checklist for creating tests.

Join us at the Maester repository discussions or Entra Discord for more help and conversations!
While you wait for a review, why not spread some Maester love on social media? Thank you! 💖

Original prompt

The GitHub Actions job build-validation is failing on the Windows runner in workflow .github/workflows/build-validation.yaml.

Observed failure:

  • Workflow run: 26758690955
  • Job: 78865647999
  • PR: Update Entra ID role definitions #1811
  • Repository: maester365/maester
  • Commit: b27f3a2817968c90d208b02e9801379e4d35b21a
  • The failure occurs in the Install PowerShell dependencies step.
  • The log shows the process exits immediately after attempting to run:
    Install-Module Microsoft.PowerShell.PSResourceGet -Force -SkipPublisherCheck -Scope CurrentUser -AllowClobber -ErrorAction Stop
  • The process exits with code -1073741502, which indicates a shell/process-level failure rather than a catchable PowerShell exception.

Relevant file:

  • .github/workflows/build-validation.yaml

Current behavior:

  • The workflow installs several PowerShell modules on every matrix leg, including Windows.
  • The Microsoft.PowerShell.PSResourceGet install is wrapped in try/catch, but the process appears to terminate before PowerShell can catch the exception.

Requested change:

  • Update the workflow so the Microsoft.PowerShell.PSResourceGet installation is skipped on Windows runners.
  • Keep the rest of the dependency installation unchanged.
  • Preserve existing workflow behavior for Linux and macOS runners.
  • Prefer a minimal, targeted change.

Acceptance criteria:

  • The Windows leg no longer attempts to install Microsoft.PowerShell.PSResourceGet.
  • Linux and macOS still attempt the install as before.
  • The workflow remains valid YAML and keeps the rest of the job behavior unchanged.
  • Open a pull request with the fix.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: Please find a solution for this failing job. Use the logs, job definition, and any referenced files where the failure occurred. Keep your response focused on the solution and include code suggestions when appropriate.

Assistant: The failure is in the Windows leg during Install PowerShell dependencies in .github/workflows/build-validation.yaml at lines 40-55.

What failed

The log shows the step died immediately after running:

try {
  Install-Module Microsoft.PowerShell.PSResourceGet -Force -SkipPublisherCheck -Scope CurrentUser -AllowClobber -ErrorAction Stop
}
catch {
  Write-Warning "Unable to install Microsoft.PowerShell.PSResourceGet: $($_.Exception.Message)"
}

but instead of throwing a catchable PowerShell exception, the process exited with:

Process completed with exit code -1073741502

That means the shell crashed/terminated at process level, so the try/catch cannot handle it. Since this happens in the generic dependency install step for all matrix legs, the most likely fix is to avoid installing Microsoft.PowerShell.PSResourceGet on the Windows runner in this workflow unless it is strictly required.

Recommended fix

Gate that install to non-Windows runners, or make it optional by OS. Based on the workflow, nothing later in this job appears to require PSResourceGet specifically.

Update .github/workflows/build-validation.yaml:

      - name: Install PowerShell dependencies
        if: steps.filter.outputs.pwshmodule == 'true'
        shell: pwsh
        run: |
          # Pester 5.7.1+ is required for the coverage configuration used in pester.ps1.
          # Installed on every leg so behavior stays consistent across the matrix.
          Install-Module Pester -MinimumVersion 5.7.1 -Force -SkipPublisherCheck -Scope CurrentUser -AllowClobber
          Install-Module PSFramework -Force -SkipPublisherCheck -Scope CurrentUser -AllowClobber
          Install-Module PSModuleDevelopment -Force -SkipPublisherCheck -Scope CurrentUser -AllowClobber
          Install-Module Microsoft.Graph.Authentication -Force -SkipPublisherCheck -Scope CurrentUser -AllowClobber

          if ($env:RUNNER_OS -ne 'Windows') {
            try {
              Install-Module Microsoft.PowerShell.PSResourceGet -Force -SkipPublisherCheck -Scope CurrentUser -AllowClobber -ErrorAction Stop
            }
            catch {
              Write-Warning "Unable to install Microsoft.PowerShell.PSResourceGet: $($_.Exception.Message)"
            }
          }
          else {
            Write-Host "Skipping Microsoft.PowerShell.PSResourceGet install on Windows runner."
          }

Why this is the best targeted solution

  • The failure occurs before tests run.
  • It happens inside the PSResourceGet install block.
  • The process exits hard, so wrapping it in try/catch is not enough.
  • The workflow does not show any later step that depends on PSResourceGet.

If PSResourceGet is actually needed on Windows

A safer variant is to isolate it in its own step so a crash does not mask which dependency caused the issue:

      - name: Install Mic...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

*This pull request was created from Copilot chat.*
>

@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented Jun 1, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Jun 1, 2026

Deploying maester with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6fc7147
Status: ✅  Deploy successful!
Preview URL: https://126af613.maester.pages.dev
Branch Preview URL: https://copilot-fix-build-validation-cza8.maester.pages.dev

View logs

Copilot AI changed the title [WIP] Fix build-validation job failure on Windows runner Skip PSResourceGet install on Windows in build-validation workflow Jun 1, 2026
Copilot AI requested a review from SamErde June 1, 2026 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants