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
- if ($flag -eq “1”){
- ($feedback.servers.($id)).servers[$i].hostname
- $verzameling += ($feedback.servers.($id)).servers[$i].hostname
- Write-host “$(($feedback.servers.($id)).servers[$i].hostname) ***************************” -ForegroundColor Green
- }
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