Read-Host

noun

say it: “REED HOHST” /ˈrid ˈhoʊst/

A PowerShell command that asks a question, waits for the person to type an answer and press Enter, and hands back what they typed.

What does Read-Host do?

Read-Host prints a question, waits for Enter and hands back what was typed. The answer is always text, so put [int] in front when you need a number. A script that runs with nobody watching can't answer it, so give that kind of script parameters instead.

$days = [int](Read-Host 'How many days back should I look')
# How many days back should I look: 7
$days + 1
# 8

In a sentence

  • “Sam's brother answered the Read-Host question with 7 and pressed Enter.”
  • “The backup menu uses Read-Host to ask which choice you want.”

Level: Apprentice · More PowerShell terms at this level

Updated