Powershell Form – Foreach loop Duplicate


I’ve been working on a form script that gets names as input, adds them to a list and runs a foreach loop for each name in the list. The issue I’m encountering is that the output or the script run in the loop gets duplicated each run. (eg. Name, Name Name, Name Name Name)

Here is the code: https://pastebin.com/FxQmKWAx

I’ve removed most of the script inside the foreach loop and other form items and placed a Write-Host, so you can see the issue. I think the problem starts at line #203, where the first OK button is pressed.

Here’s the output of the run: First run: Name

Second run: Name Name

Third run: Name Name Name

Thanks in advance!

submitted by /u/xlrod
[link] [comments]

Leave a Reply