# export csv outputs object type, not value

**URL:** <https://forums.powershell.org/t/export-csv-outputs-object-type-not-value/6563>\
**Category:** PowerShell Help\
**Created:** [June 2, 2016, 12:19pm UTC](https://forums.powershell.org/t/export-csv-outputs-object-type-not-value/6563 "2016-06-02T12:19:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![chris-agostini](https://avatars.discourse-cdn.com/v4/letter/c/4da419/32.png) [@chris-agostini](https://forums.powershell.org/u/chris-agostini)\
**Post date:** [June 2, 2016, 12:19pm UTC](https://forums.powershell.org/t/export-csv-outputs-object-type-not-value/6563/1 "2016-06-02T12:19:40Z")

</div>

When I run the script below, instead of the values of each object being output to a csv, they are output like the following:

IsReadOnly IsFixedSize IsSynchronized Keys Values SyncRoot Count  
FALSE FALSE FALSE System.Collections.Hashtable+KeyCollection System.Collections.Hashtable+ValueCollection System.Object 3  
FALSE FALSE FALSE System.Collections.Hashtable+KeyCollection System.Collections.Hashtable+ValueCollection System.Object 3  
…ect

Anyone know what is going on?

This is the script:

```
$90 = (get-date).adddays(-90);
$path = (Get-ChildItem "C:\Program Files" -Recurse ) | % { $_.FullName }
$hash = foreach ($p in $path) {
$val = Get-Item -Path $p
if ($val.LastWriteTime -lt $90) {
	[pscustomobject]@{
	Item=$val.FullName
	lastAccess=$val.LastAccessTime 
	lastWrite=$val.LastWriteTime }}}
$hash | Export-Csv C:\scripts\accessed.csv -NoTypeInformation
```

---

<div class="post-metadata">

**Author:** ![donj](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/donj/32/137_2.png) [@donj](https://forums.powershell.org/u/donj)\
**Post date:** [June 2, 2016, 12:35pm UTC](https://forums.powershell.org/t/export-csv-outputs-object-type-not-value/6563/2 "2016-06-02T12:35:41Z")

</div>

Wow, that’s a convoluted little chunk of code ;). What are you getting if you pipe $hash to Get-Member before exporting it? It’s possible the way you’re loading $hash is making it so Export-Csv isn’t treating it correctly, but can’t be sure.

---

<div class="post-metadata">

**Author:** ![chris-agostini](https://avatars.discourse-cdn.com/v4/letter/c/4da419/32.png) [@chris-agostini](https://forums.powershell.org/u/chris-agostini)\
**Post date:** [June 2, 2016, 1:32pm UTC](https://forums.powershell.org/t/export-csv-outputs-object-type-not-value/6563/3 "2016-06-02T13:32:06Z")

</div>

PS C:\scripts\> $hash | gm

TypeName: System.Collections.Hashtable

Name MemberType Definition

* * *

Add Method System.Void Add(System.Object key, System.Object value)  
Clear Method System.Void Clear()  
Clone Method System.Object Clone()  
Contains Method bool Contains(System.Object key)  
ContainsKey Method bool ContainsKey(System.Object key)  
ContainsValue Method bool ContainsValue(System.Object value)  
CopyTo Method System.Void CopyTo(array array, int arrayIndex)  
Equals Method bool Equals(System.Object obj)  
GetEnumerator Method System.Collections.IDictionaryEnumerator GetEnumerator()  
GetHashCode Method int GetHashCode()  
GetObjectData Method System.Void GetObjectData(System.Runtime.Serialization.SerializationInfo inf…  
GetType Method type GetType()  
OnDeserialization Method System.Void OnDeserialization(System.Object sender)  
Remove Method System.Void Remove(System.Object key)  
ToString Method string ToString()  
Item ParameterizedProperty System.Object Item(System.Object key) {get;set;}  
Count Property System.Int32 Count {get;}  
IsFixedSize Property System.Boolean IsFixedSize {get;}  
IsReadOnly Property System.Boolean IsReadOnly {get;}  
IsSynchronized Property System.Boolean IsSynchronized {get;}  
Keys Property System.Collections.ICollection Keys {get;}  
SyncRoot Property System.Object SyncRoot {get;}  
Values Property System.Collections.ICollection Values {get;}

---

<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 2, 2016, 1:52pm UTC](https://forums.powershell.org/t/export-csv-outputs-object-type-not-value/6563/4 "2016-06-02T13:52:02Z")

</div>

Are you running this on PowerShell v2? That’s the only way I can see you’d wind up with a hashtable object instead of a PSObject there.

The [pscustomobject] accelerator requires PSv3 or later. In v2, use the New-Object cmdlet instead.

---

<div class="post-metadata">

**Author:** ![chris-agostini](https://avatars.discourse-cdn.com/v4/letter/c/4da419/32.png) [@chris-agostini](https://forums.powershell.org/u/chris-agostini)\
**Post date:** [June 2, 2016, 1:55pm UTC](https://forums.powershell.org/t/export-csv-outputs-object-type-not-value/6563/5 "2016-06-02T13:55:05Z")

</div>

Dave, yes, I was using version 2 : ( I did finally use the New-Object cmdlet. Thanks both for the help!

---

<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, 8:41pm UTC](https://forums.powershell.org/t/export-csv-outputs-object-type-not-value/6563/6 "2024-05-16T20:41:06Z")

</div>


