Just past a few days one of my colleagues was having trouble exporting the result that he wants. So I help him out to clarify what he must do and what must not do.
His PowerShell command was;
Get-Team | Format-Table DisplayName, MailNickName
- Format-Table or ft command is used for formatting the selected properties into table form.
- Gives you a nice view of the table form of the properties in the PowerShell console only.
- If you were to export the Format-Table into a CSV, it will look like one whole chunk together in a column.
To export the result into CSV you got to use the “Select” command and then pipe with the Export-Csv command.
- “Select” or “Select-Object” command it serves the purpose of selects specified properties of an object or set of objects.
Get-Team | Select DisplayName, MailNickName | Export-Csv "<filename.csv>"
OR
Get-Team | Select DisplayName, MailNickName > "<filename.csv>"