I find very useful being able to output data in csv files when working with PowerShell, and this is a very simple way of doing it.
Apart from specifying the name of the output file, I used followind parameters:
- The -encoding Parameter, to specify the -encoding for the exported CSV file and that way avoid encoding problems
- The –NoTypeInformation parameter to remove the type information from the CSV file that goes by the default in the first line of the file.
There are other available parameters and yo can see all of them here.
From this example you can get creative and add as many columns as you want and the type of column you prefer.
Hope you like it and find it helpful.