Why is $input not available for parameter Name?

I was writting a function using

[CmdletBinding()]
param (
    [Parameter()]
    [string]
    $input
)
$input 

>test.ps1 1

>

As i input the parameter it is still $null
And after a while i realize the parameter name “$input” cause the problem

$Input is a built-in automatic variable which is why it can’t be used for your parameter name.
Take a look at all the automatic variables that exist so you familiarize yourself with them:
Powershell Automatic Variables
Strongly Encouraged Development Guidelines

3 Likes

… adding to Courtney’s helpful answer I’d like to add that you should use a proper IDE for your code development. VSCode is a very common and recommendable choice for PowerShell scripters. It will help you avoiding a lot of silly beginner failures like the one you’re asking about. :wink:

1 Like

first i like to thank for you advice ,but but my vscode didn’t mark the error when i writting it ,is there any plugin i could use to avoid it ?

You need at least the PowerShell extension. Then it should look like this:

image

… and when you install the extension Error Lens it looks like this:

thanks for your advice

If you could, when you’re asking a powershell question, please don’t post it in uncategorized, post it in powershell help. that way when someone answers your question, you can mark their answer as the solution. Appreciate it! I fixed your post (i’ve been fixing all your other posts as you have posted them as well :slight_smile: