Skip to content

AvoidUsingPositionalParameters : This rule only fires for the cmdlets / functions loaded in the default runspace #893

Closed
@LaurentDardenne

Description

@LaurentDardenne

Same behavior that this issue #883

Steps to reproduce

 $sb={
  Function Get-MyCommand {
   param( 
    [Parameter(Mandatory=$true,Position=1)] 
   $A,
   
    [Parameter(Position=2)]
   $B,
   
    [Parameter(Position=3)]
   $C
  )
  "Test"
  }
  Get-MyCommand Get-ChildItem Microsoft.PowerShell.Management System.Management.Automation.Cmdlet
 }
 Invoke-ScriptAnalyzer -ScriptDefinition "$sb"

Expected behavior

The rule is triggered.

Actual behavior

This rule does not fire because it only calls the GetCommandInfo() method.

Environment data

> $PSVersionTable
PSVersion                      5.1.14409.1012
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0, 5.0, 5.1.14409.1012}
BuildVersion                   10.0.14409.1012
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1



> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.16.1
1.16.0

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions