Read-Host is PowerShell's cmdlet for requesting a line of input from the user.
Questions tagged [read-host]
28 questions
3
votes
1 answer
Edit pause message in powershell ISE
So, as the title says, I would like to change the message from "press enter to continue", to "press enter to return to the menu". is this possible? if so can someone hook me up with a script line for it?
I can post the code here if this may…

Heine Berg
- 43
- 1
- 5
2
votes
1 answer
Try.. catch.. finally fails during Read-Host
When the script is executing the Read-Host cmdlet, closing the window does not activate the finally block. Below is an arbitrary but minimally functional example. I'm using PowerShell 5.0. The Beep() is just to make it obvious the finally block…

Alex Buck
- 197
- 2
- 2
- 10
1
vote
2 answers
Why does Read-Host require to hit enter 2 times enter before sending result?
I have a simeple loop to read for text and also detect the escape ESC [0x1b = chr(27)] key, to quit.
The Expected Behaviour
# Some Output
,
...

not2qubit
- 14,531
- 8
- 95
- 135
1
vote
1 answer
Multiple inputs in PowerShell
I have script where I ask for the user ID and I use $userName in all my commands.
Now I would like to also have the option to enter the PC name and turn back to the user ID, (if the user ID cannot be found it displays a custom error message). The…

Toon
- 29
- 8
1
vote
3 answers
Extracting column data from multiple line returns in CSV
I have a CSV file with 3 columns: Name, Job, And Directory.
I'm trying to Have the user type in Either a Name, or a Job, and it will return one or multiple lines output from column 3 (Directories)
$Profile = $PSScriptRoot + "\Profile.csv"
…

Justin.k
- 9
- 3
1
vote
0 answers
Autocomplete with TAB Read-host
I'm searching for something to autocomplete a user input in a Read-Host in Powershell. In my case, there is a list of 5 esxi hosts the user should be able to TAB through. Is there any way to do this inside of a Powershell script?
cheers,
Jonas

Jonas Stadler
- 11
- 1
1
vote
4 answers
PowerShell multiplier not recognized using Read-Host
Is there a way to get Read-Host to recognize PowerShell multipliers like KB, MB,GB,TB, and PB? The first example works just fine if I populate the $freespace variable by hand but does not work in the second example using Read-Host to populate the…

Christian McGhee
- 114
- 4
1
vote
2 answers
Powershell - Allow and Parse Multiple Line Paste
I'm working on a PS script that will allow a user to paste a bunch of emails on the command line, then the script will parse each one out and run another function on them.
I've looked around for a solution as well as played around in VS Code, but…

CDav117
- 15
- 5
1
vote
0 answers
Powershell. Use PSCredential to view a secure string. Is this technique secure?
There are many posts on viewing and comparing secureString objects. Many use .Net's Marshal method, which even its advocates admit is convoluted. A quicker method involves placing the secure string into a PSCredential object and using the…

Bagheera
- 1,358
- 4
- 22
- 35
1
vote
2 answers
Why is the "Read-host" section running before the code?
I just wanted a .ps1 file that will run a simple line of powershell but not close instantly.
Ive tried to do "read-host -prompt " " " but it is displaying before the code is run and then still closes instantly
get-appxpackage -allusers | select…

Jordan
- 25
- 3
1
vote
1 answer
Automate PowerShell Response to prompt
Creating a PowerShell script that calls an apps cmdlet. When then cmdlet runs it prompts for a response and the scripts hangs. The cmdlet doesn't have any parameters for this. Is there any way to respond programmatically? I tried ECHO but that…

TMAC 23
- 93
- 6
1
vote
1 answer
Powershell if -lt problem; returns true if the condition is false
I have a problem with small script in Powershell.
Here is my script:
$number = Read-Host "Enter a number"
if ($number -lt 3){
Write-Host "Number is too low."
break
}
But when I enter 25, for example, the if conditional still evaluates to…

Michal
- 61
- 9
0
votes
2 answers
How do I check if a password in a System.Security.SecureString is empty?
I'm prompting in a script for the user to enter a password for a new account. I know that using the -AsSecureString parameter causes it to return a System.Security.SecureString object.
$AccountPassword = Read-Host -AsSecureString -Prompt…

Randy Orrison
- 1,259
- 2
- 15
- 14
0
votes
2 answers
Taking input from user changing to multiple variables powershell
Im trying to write a script that takes the name of a divison we have and outputs the user. For starts i have a script that will filter based on AD Description, and will spit out the desired users in said division. However these are div codes and not…

Mass
- 1
- 1
0
votes
0 answers
two words as one value in user prompt read-host powershell
User Input has two words in it. for e.g. "Reflect UI" When the user presses the space key it treats "UI" as a 2nd word. You can see this also in the color change of the 2nd word. (changes to purple) Is there a way to write the read-host prompt to…

Costa
- 39
- 6