You are doing the Export-Csv inside the getAvgForSelectedVMs function and inside the foreach loop, without an Append switch, hence overwriting that CSV each time you loop through the foreach.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference