PowerTip: Don’t Name a Variable $input

Doctor Scripto

Summary: Advice against using $input for a variable name.

Hey, Scripting Guy! Question Can I use a variable named $input to hold input from the Read-Host cmdlet?

Hey, Scripting Guy! Answer $input is an automatic variable that is used for script blocks in the middle of a pipeline.

As such, it would be a very poor choice. 

Call the variable something like $userInput if you wish; but please do not call it $input


Discussion is closed.

Feedback usabilla icon