# export to one CSV with multiple headings

**URL:** <https://forums.powershell.org/t/export-to-one-csv-with-multiple-headings/1552>\
**Category:** PowerShell Help\
**Created:** [December 31, 2011, 6:30pm UTC](https://forums.powershell.org/t/export-to-one-csv-with-multiple-headings/1552 "2011-12-31T18:30:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![archives](https://avatars.discourse-cdn.com/v4/letter/a/bb73d2/32.png) [@archives](https://forums.powershell.org/u/archives)\
**Post date:** [December 31, 2011, 6:30pm UTC](https://forums.powershell.org/t/export-to-one-csv-with-multiple-headings/1552/1 "2011-12-31T18:30:00Z")

</div>

by sipho at 2012-12-20 12:00:12

> Hi,  
>   
> I am new to powershell and I can sort of modify scripts but my current task I feel is way out of my league…  
> I have two power shell script and they are:  
>   
> **import-csv input.csv | Get-MailboxStatistics | ft DisplayName, TotalItemSize, ItemCount -auto \> C:\Logs\logs.csv  
> import-csv input.csv | Get-mailbox |select RecipientTypeDetails, displayname, IssueWarningQuota|export-csv C:\Logs\logs.csv -NoTypeInformation**  
>   
> How do I get the information that I require from both these scripts into 1 single CSV called logs.csv …the input.csv contains the same info which is the SMTP address of the users with A1 as identity.   
> I want to join both these scripts into one…just not sure how to pipe that…  
>   
> Thanks  
>   
> S

by DonJ at 2012-12-20 13:57:17

> CSV isn’t designed to do that, and the resulting file would not be a valid CSV. The problem is that your two commands are creating different output; CSV assumes that every line will contain the exact same columns.  
>   
> If you simply want to jam the second set of CSV information at the end of the first…  
>   
> import-csv input.csv | Get-mailbox |select RecipientTypeDetails, displayname, IssueWarningQuota|convertto-csv \>\> C:\Logs\logs.csv  
>   
> But there’s no way to make that a valid CSV file.

by ArtB0514 at 2012-12-21 11:03:24

> On the other hand, you can create a single CSV with data from two different queries. Basically, you create a new object type and load it from both queries.  
>   
> `$MergedData=@()Import-CSV Input.csv | foreach { $stat = Get-MailboxStatistics $.<identityProperty> | Select DisplayName, TotalItemSize, ItemCount $mbx = Get-mailbox $.<identityProperty> |select RecipientTypeDetails, displayname, IssueWarningQuota $MergedData = New-Object PSObject -Property @{ 'DisplayName' = $stat.DisplayName 'Size' = $stat.TotalItemSize 'Count' = $stat.ItemCount 'Type' = $mbx.RecipientTypeDetails 'Warning' = $mbx.IssueWarningQuota }}$MergedData | Export-Csv C:\Logs\logs.csv -NoTypeInformation`

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 9:02pm UTC](https://forums.powershell.org/t/export-to-one-csv-with-multiple-headings/1552/2 "2024-05-16T21:02:17Z")

</div>


