Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read-Host always ends in a colon

Whenever I do a Read-Host the prompt always ends in : is there anyway to change this? is it -Prompt Flag?

like image 839
Geremachek2 Avatar asked Jun 10 '18 21:06

Geremachek2


1 Answers

As mentioned in the comments, there's no way to control how the executing host application presents the prompt when passing a Prompt message parameter argument.

What you can do instead, is call $Host.UI.ReadLine() directly from your script and prepend a message yourself:

Write-Host "No colons here>" -NoNewLine
$UserInput = $Host.UI.ReadLine()

Here's an example of what that looks like in powershell.exe:

Read-HostCustom function

like image 131
Mathias R. Jessen Avatar answered Nov 17 '22 18:11

Mathias R. Jessen