Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Reply To: Cannot use variable as a get-adcomputer filter parameter

$
0
0

You’re exporting to the CSV file inside a loop (and without the -Append parameter, which was added in PowerShell 3.0). Typically, what you’d want to do in PowerShell is have your Get-ComputerInfo function just output objects, and then the caller can choose to pipe that to Export-Csv or whatever they need to do. But if you do choose to create the CSV inside the function, you either need to move the call to Export-Csv outside the loop body (ideally using a ForEach-Object pipeline instead of a foreach loop, so you can pipe the results straight to Export-Csv), or just add the -Append parameter to the Export-Csv call inside the loop.


Viewing all articles
Browse latest Browse all 13067

Trending Articles