array not filling

Welcome Forums General PowerShell Q&A array not filling

This topic contains 2 replies, has 2 voices, and was last updated by

2 months, 2 weeks ago.

  • Author
  • #164151

    Topics: 1
    Replies: 1
    Points: 14
    Rank: Member

    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 🙂


  • #164193

    Topics: 25
    Replies: 678
    Points: 1,629
    Helping Hand
    Rank: Community Hero

    Wow, how did you make this?

    • #164199

      Topics: 1
      Replies: 1
      Points: 14
      Rank: Member

      Its input I get from a program through api 🙂

You must be logged in to reply to this topic.