1

Want to pull off something similar to " set /p variable = x " from batch.

How can we make this happen in PS1?

Script example that im using

Function Prompt { 'PS' + $x + '>' }
2
  • Inside the function, first determine the value for $x I would imagine.. Commented Feb 5, 2021 at 10:32
  • What does the set /p variable = x actually do for your in batch? Commented Feb 5, 2021 at 12:55

1 Answer 1

2

The equivalent to set /p in PowerShell would be Read-Host:

$value = Read-Host "Give me some input"

The host application (eg. powershell.exe) will now prompt the user for input with the caption Give me some input:, and the result will be stored in $value

enter image description here

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

1 Comment

This indeed is exactly what I asked for, thank you.

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.