Skip to content

Using a dynamicparam block in an advanced function causes invocations with the -PipelineVariable common parameter to fail #6420

@mklement0

Description

@mklement0

An (adapted) copy of this uservoice issue first reported by @PetSerAl in 2014:

Using a dynamicparam block in an advanced function causes invocations with the -PipelineVariable common parameter to fail.

Steps to reproduce

function foo {
  [CmdletBinding()]
  param()
  dynamicparam { }
  process { 'hi' }
}

foo -PipelineVariable bar

Expected behavior

hi

Actual behavior

The following error is reported:

foo : Cannot retrieve the dynamic parameters for the cmdlet. Object reference not set to an instance of an object.
...

Note that it doesn't make a difference whether the dynamicparam block is empty or not.

Environment data

PowerShell Core v6.0.2 on macOS 10.13.3
PowerShell Core v6.0.2 on Ubuntu 16.04.3 LTS
PowerShell Core v6.0.2 on Microsoft Windows 10 Pro (64-bit; v10.0.15063)
Windows PowerShell v5.1.15063.674 on Microsoft Windows 10 Pro (64-bit; v10.0.15063)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions