# array not filling

**URL:** https://forums.powershell.org/t/array-not-filling/12812
**Category:** PowerShell Help
**Created:** [July 4, 2019, 3:22am UTC](https://forums.powershell.org/t/array-not-filling/12812 "2019-07-04T03:22:03Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![seguino](https://avatars.discourse-cdn.com/v4/letter/s/d6d6ee/32.png) [@seguino](https://forums.powershell.org/u/seguino)
#### Post date: [July 4, 2019, 3:22am UTC](https://forums.powershell.org/t/array-not-filling/12812/1 "2019-07-04T03:22:03Z")

</div>

Good day,  
I am working on an export. And probably I make a very simple mistake, but I am unable to discover what I’m doing wrong.  
Its a big script but I will only copy the relevant portion of it  
$verzameling = @()

here is looping code with all kind of stuff and in this stuff is

1. if ($flag -eq “1”){
2. ($feedback.servers.($id)).servers[$i].hostname
3. $verzameling += ($feedback.servers.($id)).servers[$i].hostname
4. Write-host “$(($feedback.servers.($id)).servers[$i].hostname) \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*” -ForegroundColor Green
5. }

I numbered the lines (of course only here)  
Line 2 I added to test if the variable is filling the right way and the right value is shown when run. So I know the array does not stay empty because the input is not empty.  
Line 4 is for feedback for the person who runs the script and this line is working aswel.  
Line 3 is the line where I want to add every server that has flag -eq 1 according to line 1 to be added to the array $verzameling

The weird thing is when I manually type line 3 and $i = 0 the line is added. But when running the script the array stays empty.

Thank you for taking the time to read my message 🙂

&nbsp;

---

<div class="post-metadata">

### Author: ![js2010](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@js2010](https://forums.powershell.org/u/js2010)
#### Post date: [July 4, 2019, 10:09am UTC](https://forums.powershell.org/t/array-not-filling/12812/2 "2019-07-04T10:09:07Z")

</div>

Wow, how did you make this?

```
($feedback.servers.($id)).servers[$i].hostname
```

---

<div class="post-metadata">

### Author: ![seguino](https://avatars.discourse-cdn.com/v4/letter/s/d6d6ee/32.png) [@seguino](https://forums.powershell.org/u/seguino)
#### Post date: [July 4, 2019, 10:15am UTC](https://forums.powershell.org/t/array-not-filling/12812/3 "2019-07-04T10:15:50Z")

</div>

Its input I get from a program through api 🙂

---

<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:32pm UTC](https://forums.powershell.org/t/array-not-filling/12812/4 "2024-05-16T20:32:03Z")

</div>


