PowerShell / PowerShell/PSScriptAnalyzer

On github actions ubuntu-latest analysis fails with "The term 'Get-Command' is not recognized as a name of a cmdlet"

Open
#2,205 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
2.2k
Forks
414
Avg merge
13h 1m
Merged PRs (30d)
2

Description

I can't exactly pinpoint what causes this. When I run the pwoershell script analyzet 1.25 on Ubuntu-latest github runners against a powershell 7 project, the analyzer fails to complete its analysis and throws:

Invoke-ScriptAnalyzer: /home/runner/work/_temp/e8c5014b-7f61-4956-b6d1-75953a6d07f6.ps1:7
Line |
   7 |  $results = Invoke-ScriptAnalyzer -Path './' -Recurse -Settings 'PSScr …
     |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | The term 'Get-Command' is not recognized as a name of a cmdlet,
     | function, script file, or executable program. Check the spelling of the
     | name, or if a path was included, verify that the path is correct and try
     | again.

Reverting to 1.24 does not exhibit the issue.

Failing workflow run 1.25:
https://github.com/jessehouwing/actions-semver-checker/actions/runs/32254079386/job/96071605798

Working workflow run 1.24:
https://github.com/jessehouwing/actions-semver-checker/actions/runs/32257267058

No changes other than changing the pinned version:
https://github.com/jessehouwing/actions-semver-checker/pull/454

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the linked failing Ubuntu-latest workflow run using PSScriptAnalyzer 1.25 with the working 1.24 run; the report says the only change is the pinned version. Reproduce the analysis against a PowerShell 7 project and determine why 1.25 cannot resolve Get-Command. Done means the 1.25 analysis completes successfully on the same workflow without reverting to 1.24.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions, powershell, ubuntu
Domain
ci-cd
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.