You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
On github actions ubuntu-latest analysis fails with "The term 'Get-Command' is not recognized as a name of a cmdlet" #2205
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.
I had copilot review the 1.24.0 → 1.25.0 source delta and narrowed the failure path down to the internal command-information lookup used by PSAvoidUsingCmdletAliases.
AvoidAlias.AnalyzeScript() calls Helper.Instance.GetCommandInfo() for each non-alias command. That delegates to CommandInfoCache, which creates a pooled child runspace and runs Get-Command through PowerShell.Create().
The direct 1.25.0 change to that path is #2125 (commit 8bde45d): it now parses a Module\\\\Command name and adds -Module to the internal Get-Command invocation. The reported error is emitted by that child invocation, and the exception is not handled by CommandInfoCache, so one unavailable command lookup aborts the entire analyzer run instead of being treated as an unresolved command.
There was also an upgrade of the System.Management.Automation build reference from 7.4.7 to 7.4.14 in #2143. That makes the pooled child-runspace behavior on the current hosted-runner PowerShell version a likely compatibility boundary.
Suggested defensive fix: make CommandInfoCache.GetCommandInfoInternal() handle CommandNotFoundException / failed ps.Invoke() results and return null (optionally logging a diagnostic) rather than propagating the exception. The rules already handle null as “cannot resolve this command,” so this preserves analysis. It would also be useful to add an Ubuntu-hosted-runner regression test that exercises the cache with PSAvoidUsingCmdletAliases enabled.
I cannot prove #2125 alone triggers this repository’s exact invocation—the repository does not appear to use module-qualified command invocations—but it is the only 1.25.0 source modification of this lookup mechanism and is the most focused investigation point.
Activity
jessehouwing commentedon Aug 19, 2026
I had copilot review the 1.24.0 → 1.25.0 source delta and narrowed the failure path down to the internal command-information lookup used by
PSAvoidUsingCmdletAliases.AvoidAlias.AnalyzeScript()callsHelper.Instance.GetCommandInfo()for each non-alias command. That delegates toCommandInfoCache, which creates a pooled child runspace and runsGet-CommandthroughPowerShell.Create().The direct 1.25.0 change to that path is #2125 (commit 8bde45d): it now parses a
Module\\\\Commandname and adds-Moduleto the internalGet-Commandinvocation. The reported error is emitted by that child invocation, and the exception is not handled byCommandInfoCache, so one unavailable command lookup aborts the entire analyzer run instead of being treated as an unresolved command.There was also an upgrade of the
System.Management.Automationbuild reference from 7.4.7 to 7.4.14 in #2143. That makes the pooled child-runspace behavior on the current hosted-runner PowerShell version a likely compatibility boundary.Suggested defensive fix: make
CommandInfoCache.GetCommandInfoInternal()handleCommandNotFoundException/ failedps.Invoke()results and returnnull(optionally logging a diagnostic) rather than propagating the exception. The rules already handlenullas “cannot resolve this command,” so this preserves analysis. It would also be useful to add an Ubuntu-hosted-runner regression test that exercises the cache withPSAvoidUsingCmdletAliasesenabled.I cannot prove #2125 alone triggers this repository’s exact invocation—the repository does not appear to use module-qualified command invocations—but it is the only 1.25.0 source modification of this lookup mechanism and is the most focused investigation point.