Gather info through several foreach and then export-csv at the end of script
问题 I have a script that scans all my servers in my domains and outputs to two separate CSV files - one simple and one extensive. I write one line at the time to my csv.. This results in thousands of file-open and file-close.. I've lurked around and understand that I should first gather all the info and write it all in one sweep at the end of the script. But how do I do this with export-csv (preferably using a function)? And is there a way I can use the same function for short and long list? The