Powershell - Read-Host Cmdlet
Advertisements
Cmdlet
Read-Host cmdlet is used to read from the console.
In these example, we're see the Read-Host cmdlet in action.
Example
In this example, we'll ask the user to pass an input and read the input into a variable.
$choice = Read-Host "Please put your choice"
Powershell will show a popup to enter the value. Once you enter the value, it is saved in $choice variable. Now print the variable.
$choice
Output
You can see the value of variable.
1
powershell_advanced_cmdlets.htm
Advertisements