# Script beginer

**URL:** <https://forums.powershell.org/t/script-beginer/13754>\
**Category:** PowerShell Help\
**Created:** [February 3, 2020, 2:35pm UTC](https://forums.powershell.org/t/script-beginer/13754 "2020-02-03T14:35:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dwaynes](https://avatars.discourse-cdn.com/v4/letter/d/57b2e6/32.png) [@dwaynes](https://forums.powershell.org/u/dwaynes)\
**Post date:** [February 3, 2020, 2:35pm UTC](https://forums.powershell.org/t/script-beginer/13754/1 "2020-02-03T14:35:16Z")

</div>

I am new to scripting all together and am trying to figure out how I can cycle through this variable so that the command can use the same variable to work. Any assistance would be appreciated.

&nbsp;

$server=‘dc2pa90048,tocpaIIB-TI,lsys7011a-TI’

pairdisplay -IM100 -g $server -fcx  
start-sleep -s 2

---

<div class="post-metadata">

**Author:** ![rob-simmers](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rob-simmers/32/1010_2.png) [@rob-simmers](https://forums.powershell.org/u/rob-simmers)\
**Post date:** [February 3, 2020, 3:04pm UTC](https://forums.powershell.org/t/script-beginer/13754/2 "2020-02-03T15:04:02Z")

</div>

There are some great books for beginners, especially if you have no scripting experience.

Powershell is full of help files and there a ton of free videos, blogs, etc. available. The short answer is you need to look at [arrays](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_arrays?view=powershell-7) and [foreach loop](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_foreach?view=powershell-7). Another important item is [operators](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_operators?view=powershell-7), specifically call operators to call external non-Powershell commands.

```
$servers =' dc2pa90048','tocpaIIB-TI','lsys7011a-TI'

foreach ($server in $servers) {
    & pairdisplay -IM100 -g $server -fcx
    start-sleep -s 2
}
```

Please also re-read [Read Me Before Posting! You’ll be Glad You Did!](https://powershell.org/forums/topic/read-me-before-posting-youll-be-glad-you-did/) and ensure you use the PRE tags for your code.

---

<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:30pm UTC](https://forums.powershell.org/t/script-beginer/13754/3 "2024-05-16T20:30:44Z")

</div>


