This chapter will provide examples where you can add interactive input to your scripts (i.e., the script will ask for input such as entering a password or another attribute such as the path of a CSV or text file).
© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2022
V. SukhijaPowerShell Fast Track https://doi.org/10.1007/978-1-4842-7759-1_44. Interactive Input
Vikas Sukhija1
(1)
Waterloo, ON, Canada
You have used Write-host for printing value to the screen. Now you can use Read-host
to get values that are input by a user on the screen:
$x =Read-host "input your Name"
The value of your input is saved in an $x variable so you can use it in the script for further processing, as shown in Figure 4-1.
Get PowerShell Fast Track: Hacks for Non-Coders now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.