1
function User-Search($input)
{
    Write-Host "Searching for user: $input"
    pause
}


function Show-Menu
{
     param (
           [string]$Title = 'MainMenu'
     )
     cls
     Write-Host "================ $Title ================"
     Write-Host " "
     Write-Host "Specify computer / username"
     Write-Host " "
     Write-Host "Q: Press 'Q' to quit."
     Write-Host " "
}

do
{
    Show-Menu
    $input = Read-Host "Search"
    User-Search -input $input
}
until ($input -eq 'q')

Outputs: "Searching for user:", it's empty.

There must be some small mistake i am doing, probably easy for you guys :)

1
  • Don't use $input as self-defined variable name, because it is an Automatic variable in PowerShell. Commented Feb 28, 2020 at 10:31

1 Answer 1

3

$INPUT is an automatic variable:

Contains an enumerator that enumerates all input that is passed to a function. The $input variable is available only to functions and script blocks (which are unnamed functions).

So just use another variable, e. g. $user instead of $input

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.