-2

In my profile script for powershell I want to write to user input, so that when i start powershell I will already have something in my input and have only to press enter. I need something like "write-input".

I have already tries "echo", "write-input".

3
  • What's your use case? This sounds potentially dangerous. Commented Jan 2, 2014 at 14:18
  • I user powershell always to execute the same commands so I wanted to have the most used already typed in as i start powershell Commented Jan 2, 2014 at 15:16
  • 3
    Why not make them functions and/or aliases in your profile then? Think about it: you're trying to save a handful of keystrokes only when starting PowerShell. I start a new PowerShell console once every few days - pre-typing something is not a significant "savings" unless you're constantly killing & restarting PowerShell, which seems wasteful to me. Commented Jan 2, 2014 at 15:29

1 Answer 1

2

I would do something like:

$defaultvalue = "This is the default value"
$a = read-host -Prompt "$defaultvalue (enter)"
if (!$a) {$a = $defaultvalue}
write-host "the value is now $a"
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.