Help with Foreach loop - TextBox on Windows Form RRS feed

  • Question

  • I have written a script that will accept an AD query (computer hostname) and collect information on each item in the query results, then feed this information into an Access DB. I have a small GUI form that will take the users input (query) and also has a progress bar for monitoring the foreach iteration. I have added an additional textbox on the form wth the intentions of displaying the currently processing item while the progress bar is moving. The problem is, with changing the text in the textbox as part of the foreach loop, the entire loop has to finish before the textbox text is changed which would mean that the displayed name would not be the currently processing item. Below is the foreach loop. For testing purposes i have removed all the info-collection code and simplified it to basically just the progressbar. I have racked my brain to find another way of doing this. Immense thanks to anyone that can help. Function Inventory { $Computers = ADSearch $Args[0] Foreach ($Computer in $Computers) { $tbxProcessing.Text = $Computer $pgbProgress.Value = 25 start-sleep -s 1 $pgbProgress.Value = 50 start-sleep -s 1 $pgbProgress.Value = 75 start-sleep -s 1 $pgbProgress.Value = 100 start-sleep -s 1 $pgbProgress.Value = 0 start-sleep -s 4 } }
    • Changed type BlaylockBW Wednesday, February 16, 2011 3:46 PM
    • Edited by BlaylockBW Wednesday, February 16, 2011 3:49 PM Foreach Loop
    • Moved by Hengzhe Li Tuesday, April 19, 2011 3:27 AM Forum Cleanup (From:MSDN, TechNet, and Expression Profile and Recognition System Discussions)
    Wednesday, February 16, 2011 3:45 PM