PowerShell / PowerShell/PSScriptAnalyzer

Ability to bind concerned PowerShell version to a rule

Open
#2,050 0 comments 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

It might be helpful that in the case a rule only applies to a specific (minimum) PowerShell versions as for e.g.:

And new request/issues:

to have the possibility to add that (minimum) PowerShell version (e.g. MininumPowerShellVersion) to that rule.

Meaning e.g. the AvoidUsingWMICmdlet rule might have MininumPowerShellVersion set to 3.0
This would add the possibility for two additional features:

  • Suppressing the specific rule by using the #Requires -Version x.x statement.
    E.g.:
    • adding #Requires -Version 2.0 would suppress the AvoidUsingWMICmdlet rule
    • adding #Requires -Version 7.0 would allow the use of `e (suppress the proposed UseCompatibleStrings rule)
  • A general UseRequiresStatement rule when a rule with a minimal version applies and the #Requires -Version x.x is not set (or set incorrectly)
    E.g. if any of the rules applies, it generate a warning that the #Requires -Version x.x statement should be set.

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 reading the AvoidUsingWMICmdlet rule documentation and the linked UseCompatibleStrings, UseCompatibleSyntax, and AvoidNewObjectCmdlet issues. Then trace how rules are represented and how #Requires -Version is handled. Done means the proposed minimum-version behavior, suppression, and UseRequiresStatement behavior have a defined implementation scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, powershell
Domain
devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.