PowerShell / PowerShell/PSScriptAnalyzer
psdscuseidenticalmandatoryparametersfordsc errors
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 2.2k
- Forks
- 414
- Avg merge
- 13h 1m
- Merged PRs (30d)
- 2
Description
GET/SET/Test have identical parameters.
param
(
[Parameter(Mandatory=$true)]
[System.String]
$DistinguishedName,
[Parameter(Mandatory=$true)]
[Microsoft.Management.Infrastructure.CimInstance[]]
$AccessControlList,
[Parameter(Mandatory=$false)]
[bool]
$Force = $false
)
I get this error when the rule runs.
Invoke-ScriptAnalyzer : Object reference not set to an instance of an object.
At line:1 char:1
- Invoke-ScriptAnalyzer .\AccessControlDsc -Recurse -ExcludeRule 'PSUse ...
-
+ CategoryInfo : InvalidOperation: (<filepath>:String) [Invoke-ScriptAnalyzer], NullReferenceException + FullyQualifiedErrorId : RULE_ERROR,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzerCommand
If I exclude this rule then I get no errors.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the error with Invoke-ScriptAnalyzer on the AccessControlDsc path and the PSUse... rule named in the command, using the GET/SET/Test parameters shown. Trace the rule's handling of identical mandatory parameters; done means analysis completes without a NullReferenceException and reports the intended result instead.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100