Read multiple values from console

Hi New to Powershell here, trying to fumble my way through…

I’m trying to write a script to output the last 3 eventlog items from named servers to an HTML file.

I want to have a prompt ask the user which servers they want to query. I can’t quite work out how to handle multiple inputs, I think I need an array but not sure how to set it up. Can anyone give me any pointers?



The BEST way is to let PowerShell do it. At the top of your script:


If someone runs the script, they’ll be prompted for the computer name. They can keep entering them, one at a time, hitting Enter on an empty prompt to indicate they’re done. The nice thing is that they can bypass the prompt by running the script and providing a -ComputerName parameter up front.

This remains consistent with the way the shell works for all commands.

Great, thank you Don. I’ll play around with that now :slight_smile:

Works a charm, thanks again!