sourcenouveau
sourcenouveau

Reputation: 30554

PowerShell script parameters not parsed correctly

I have a simple script which does not work:

Param([string] $Input, [string] $Output)
Write-Host $Input
Write-Host $Output

The $Input parameter does not get printed:

PS> .\Get-Parameters.ps1 "First" "Second"

Second

If I rename $Input to $Joe the script works fine. $Input is not a reserved name.

What is going on? I am perplexed.

Upvotes: 1

Views: 224

Answers (2)

Webplanet TFS Consulting
Webplanet TFS Consulting

Reputation: 1269

$input in an enumerator which provides access to the pipeline you have.

reference here: $Input Gotchas

Upvotes: 1

CB.
CB.

Reputation: 60976

PowerShell's $input is an automatic variable:

basically $input in an enumerator which provides access to the actual pipeline.

Reading about $input

Upvotes: 2

Related Questions