# Export-CSV Differences

**URL:** <https://forums.powershell.org/t/export-csv-differences/24091>\
**Category:** PowerShell Help\
**Created:** [May 9, 2024, 8:32pm UTC](https://forums.powershell.org/t/export-csv-differences/24091 "2024-05-09T20:32:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Austin\_H](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/austin_h/32/4523_2.png) [@Austin\_H](https://forums.powershell.org/u/Austin_H)\
**Post date:** [May 9, 2024, 8:32pm UTC](https://forums.powershell.org/t/export-csv-differences/24091/1 "2024-05-09T20:32:25Z")

</div>

I’ve got a snippet of code that runs differently in PSVersion 5.1 and 7.4:

```powershell
"server1.domain.com","server2.domain.com" | % { @{ ComputerName = $_; CopySucceeded = ( Test-Path "C:\temp\foo.bar" ) } } | Export-Csv C:\Temp\foo.csv -Append -Force -NoTypeInformation

```

When ran in 7.4 I get these results:  
 ![image](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/2X/d/d374860217d804bf81e949ab5866e1dd287dc5e7.png)

When ran in 5.1, I get this result:  
 ![image](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/2X/e/e1dd5fa466d6c2fd0605e2023a3ed1371ec41379.png)

Does anyone know what has changed to allow this to work now in 7.4 or which version began to allow this?

I’ve been trying to mess around in 5.1 to see how to export this, but not quite getting it with `ConvertFrom-CSV`. Is there a way to `Export-CSV` in 5.1 without declaring headers to get a similar output from 7.4?

```powershell
"server1.domain.com","server2.domain.com" | ConvertFrom-Csv -Header ('ComputerName', 'CopySucceeded') | Export-Csv C:\Temp\foo5.1.csv -Append -Force -NoTypeInformation

```

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [May 9, 2024, 9:04pm UTC](https://forums.powershell.org/t/export-csv-differences/24091/2 "2024-05-09T21:04:14Z")

</div>

I’m not sure if I really get what your question is but I wonder why you’re not using it like this:

```auto
"server1.domain.com", "server2.domain.com" | 
ForEach-Object { 
    [PSCustomObject]@{
        ComputerName = $_; 
        CopySucceeded = ( Test-Path 'C:\temp\foo.bar' ) 
    } 
} | 
Export-Csv .\foo$($PSVersionTable.PSVersion.Major).csv -Force -NoTypeInformation

```

This way you have in both versions the same result. 🤷🏼‍♂️

---

<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 9, 2024, 9:20pm UTC](https://forums.powershell.org/t/export-csv-differences/24091/3 "2024-05-09T21:20:14Z")

</div>

Yea this is probably the best move.

those extra properties are basically hash table properties.

```powershell
$hashtable = @{}
$hashtable | Get-Member

```

[Release v7.2.0-preview.9 Release of PowerShell · PowerShell/PowerShell · GitHub](https://github.com/PowerShell/PowerShell/releases/tag/v7.2.0-preview.9)

[ConvertTo-Csv / Export-Csv - Serialize IDictionary objects with key/value pairs as properties by vexx32 · Pull Request #11029 · PowerShell/PowerShell · GitHub](https://github.com/PowerShell/PowerShell/pull/11029)

[Make Export-Csv and ConvertTo-Csv support hashtables (dictionaries) · Issue #10999 · PowerShell/PowerShell · GitHub](https://github.com/PowerShell/PowerShell/issues/10999)

basically its a serialization issue that was ‘fixed’ in version 7.2

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [June 8, 2024, 9:20pm UTC](https://forums.powershell.org/t/export-csv-differences/24091/4 "2024-06-08T21:20:40Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
