Contact

Subscribe via Email

Subscribe via RSS/JSON

Categories

Creative Commons Attribution 4.0 International License
© Rakhesh Sasidharan

Elsewhere

PowerShell functions can’t have a parameter called input

This bit me once in the past, and again today. What a waste of time!

PowerShell functions can’t have a parameter called input. No error is thrown when you define the parameter thus, it just doesn’t work that’s all.

What about if I try constraining the parameter type?

Still the same, just that I get a weird error too. Looks like the default parameter input is of type ArrayList.

Update: Later I learnt that all PowerShell functions have a default variable called $input (similar to the default variable $args). When the function accepts input from a pipeline this variable is what holds the input.