0

I'm using the import-csv command to pull a load of values in to populate a combobox in a Powershell script with a form. All works nicely. However in the console it displays a count of the values going in - so it shows 0,1,2,3,4 and so on.

Is it possible to suppress this? I want to have the GUI/form run without any other windows showing.

This is the code I'm using for the import.

Import-Csv "C:\Scripts\ProjectManagers.csv" |
ForEach-Object {
    $ComboBoxProjectPM.Items.Add($_.ProjectManager)
}
2
  • 2
    Assign $null to the expression. You should also be able to AddRange. Commented Apr 25, 2022 at 14:21
  • What you are describing is a common problem with adding items to list and similar objects - here is another example: stackoverflow.com/q/56965649/4190564 There are multiple methods for silencing the output, but if you look at the following answer you can see that piping to out-null is slow and should be avoided: stackoverflow.com/a/5263780/4190564 Commented Apr 25, 2022 at 15:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.