array not filling

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 :slight_smile:

 

Wow, how did you make this?

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

Its input I get from a program through api :slight_smile: