November 2018
Intermediate to advanced
566 pages
17h 15m
English
Read-Host takes input from the host, and then passes on the received object to the calling function. In our case, we have the Read-Host placed within a subexpression, and the caller is the Write-Output cmdlet. Therefore, it takes in the name as the input and then passes it on to the Write-Output cmdlet.
Optionally, if you are not comfortable using a subexpression, you can assign the value to a variable, and call the variable with Write-Output:
$Name = Read-Host "Enter your name" Write-Output "Hello, $Name!"
Read now
Unlock full access