Sorry for the wierd title, I didn't know how to phrase the question. I'm relatively new to Powershell and I'm writing a program. Basically, I have an array where the user has selected settings or wish to have "Selected" from the GWMI query stored in "$settings_array". I want to output the results to a CSV. When I try to run it, only the first Select statement gets output to the CSV. Output to the textbox works fine. I know it has something to do with how it's being stored in the array at each ieration. $resultList is intialized as an array ($resultList = @()). There are hundreds of lines of code for the Form and other functions, but here is the relevant code. Thanks for the help! Let me know if I need to post more of the code.
$colItems = GWMI Win32_NetworkAdapterConfiguration -computername $PCname -namespace "root\CimV2" -filter "IpEnabled = TRUE"
ForEach ($objItem in $colItems)
{
ForEach ($objItem2 in $settings_array)
{
$resultList += $objItem | Select $objItem2
$richTextBox1.Appendtext("$objItem2" + ": " + $objItem.$objItem2 + "`r`n")
$richtextbox1.ScrollToCaret()
}
}
$resultList | export-csv "$ScriptDir\Exports\$Outputfile"
$colItems | Select-Object -Property $settings_array | export-csv "$ScriptDir\Exports\$Outputfile" -NoTypeafter building settings array in the same function. Building $settings_array in a separate function created errors.