Problem
You want to use input from the user in your script.
Solution
To obtain user input, use the ReadHost cmdlet:
PS >$directory = ReadHost "Enter a directory name" Enter a directory name: C:\MyDirectory PS >$directory C:\MyDirectory
Discussion
The ReadHost cmdlet reads a single line of input from the user. If the input contains sensitive data, the cmdlet supports an –AsSecureString parameter to read this input as a SecureString.
If the user input represents a date, time, or number, be aware that most cultures represent these data types differently.
For more information about the ReadHost cmdlet, type GetHelp ReadHost.