在 Windows PowerShell 5.1 与 PowerShell 7 中编写和执行稳定命令,重点处理引号、管道符、原生命令参数传递与跨版本兼容。遇到 `--jq`/过滤表达式被 PowerShell 误解析、同一命令在 pwsh5 与 pwsh7 行为不一致、或需要为 pwsh7.3+ 增加参数传递适配时使用此 skill。
75
92%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
以“先兼容、后增强”为原则生成 PowerShell 命令。默认先满足 pwsh5 可运行,再按需启用 pwsh7 专属能力。
$PSVersionTable.PSVersion,判断是 5.1 还是 7.x。--% 或 pwsh7 参数传递设置。--jq 或类似参数传入含 | 的表达式时,必须使用单引号字符串。PowerShell 7.3+ 时考虑 $PSNativeCommandArgumentPassing 影响。Legacy,任务完成后恢复原值。??、||、&&、ForEach-Object -Parallel)前先做版本判断。| 被吃掉:检查表达式是否被单引号包裹。--% 或 $PSNativeCommandArgumentPassing。Plan: 要解决的 PowerShell 兼容问题。Commands: 可直接执行的命令(必要时分 5.1 与 7.x 两套)。Result: 关键输出与版本信息。Compat: 是否依赖 pwsh7 特性,及回退方案。按需加载,不要一次性读取全部细节:
references/pwsh5-baseline.md--jq 与引号规则:references/quoting-jq.mdreferences/pwsh7-adaptation.md72669fb
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.