# Read multiple values from console

**URL:** <https://forums.powershell.org/t/read-multiple-values-from-console/2116>\
**Category:** PowerShell Help\
**Created:** [December 3, 2013, 1:31am UTC](https://forums.powershell.org/t/read-multiple-values-from-console/2116 "2013-12-03T01:31:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![doug-morrison](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@doug-morrison](https://forums.powershell.org/u/doug-morrison)\
**Post date:** [December 3, 2013, 1:31am UTC](https://forums.powershell.org/t/read-multiple-values-from-console/2116/1 "2013-12-03T01:31:41Z")

</div>

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?

TIA

Doug

---

<div class="post-metadata">

**Author:** ![donj](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/donj/32/137_2.png) [@donj](https://forums.powershell.org/u/donj)\
**Post date:** [December 3, 2013, 1:55am UTC](https://forums.powershell.org/t/read-multiple-values-from-console/2116/2 "2013-12-03T01:55:42Z")

</div>

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

```
[CmdletBinding()]
Param(
  [Parameter(Mandatory=$True)][string[]]$ComputerName
)
```

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.

---

<div class="post-metadata">

**Author:** ![doug-morrison](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@doug-morrison](https://forums.powershell.org/u/doug-morrison)\
**Post date:** [December 3, 2013, 2:09am UTC](https://forums.powershell.org/t/read-multiple-values-from-console/2116/3 "2013-12-03T02:09:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![doug-morrison](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@doug-morrison](https://forums.powershell.org/u/doug-morrison)\
**Post date:** [December 3, 2013, 2:23am UTC](https://forums.powershell.org/t/read-multiple-values-from-console/2116/4 "2013-12-03T02:23:32Z")

</div>

Works a charm, thanks again!

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:52pm UTC](https://forums.powershell.org/t/read-multiple-values-from-console/2116/5 "2024-05-16T20:52:34Z")

</div>


