Thanks for posting this. We've been looking for a solution to output profile data for ages. We've been asked to output users profiles to a file and have managed to output to a csv by adding "$UserProfile.UserProfileProperties | Out-File C:\psoutputs\users.csv -append" to your code.
We are now having trouble manipulating that data into something readable as it outputs into rows instead of columns. We think we might need to define an array but have limited knowledge of PowerShell. Are you or any of your readers able to offer any advice or assistance?