PowerShell Exported CSV is Garbled?

KB ID 0001557

Problem

I was exporting a list of enabled Active Directory users to a CSV file for some documentation, the finished article was not what I was expecting;

Contents;

Microsoft.PowerShell.Commands.Internal.Format.FormatStartData
ClassId2e4f51ef21dd47e99d3c952918aff9cd, 
pageHeaderEntry
pageFooterEntry
autosizeInfo
shapeInfo
groupingEntry
033ecb2bc07a4d43b5ef94ed5a35d280
Microsoft.PowerShell.Commands.Internal.Format.AutosizeInfo
Microsoft.PowerShell.Commands.Internal.Format.TableHeaderInfo

Solution

This happens if you have used ‘Format-Table‘ in your PowerShell command. ‘Export-Csv’ does not like this, use ‘Select-Object‘ instead. e.g.

[box]

DONT USE THIS
Get-ADuser -filter *|where {$_.enabled -eq "True"} | Format-Table Surname, GivenName, Enabled, SamAccountName, UserPrincipalName, Name, DistinguishedName | Export-Csv C:\Output\Enabled-Users.csv
USE THIS
Get-ADuser -filter *|where {$_.enabled -eq "True"} | Select-Object Surname, GivenName, Enabled, SamAccountName, UserPrincipalName, Name, DistinguishedName | Export-Csv C:\Output\Enabled-Users.csv

[/box]

Related Articles, References, Credits, or External Links

NA

Exchange – Display/Export Users Mailbox Folder Sizes

KB ID 0000860 

Problem

A client asked this morning if there was a way he could see each users mailbox size, this is pretty simple to do see here. But he wanted to see each individual folder, and see a breakdown on the sizes of these folders.

Solution

Display Folder Sizes For an Individual User

From the Exchange Management Shell, execute the following command;

[box] Get-MailboxFolderStatistics pete | Select Identity,Name,FolderSize,ItemsinFolder | Export-Csv C:Petes_Folder_Size.csv[/box]

This will export to a CSV file in the location specified above.

Display Folder Sizes For All Users

From the Exchange Management Shell, execute the following command;

[box]Get-MailboxDatabase | Get-Mailbox -ResultSize Unlimited | Get-MailboxFolderStatistics | Select Identity,Name,FolderSize,ItemsinFolder | Export-Csv C:Users_Folder_Size.csv[/box]

Note: If you have less than 1000 mailboxes, you don’t need to add the ‘-ResultSize Unlimited’ switch

This will export to a CSV file in the location specified above.

Related Articles, References, Credits, or External Links

NA