Export-csv

by bronyx85 at 2013-03-27 08:46:40

Hi I have a sharepoint list, with the following columns,

Address, Status, Account Name, Title


Address is Multiple lines of Text
Status is Single Line of Text
Title is Single Line of Text
Account Name is a person and group field.

I run the following script on the list

$web = Get-SPWeb mylist
$splist = $web.Lists["My List Name"]
$view = $splist.Views["All Items"]
$items = $splist.GetItems($view)
$items | Select-Object Address, Status, AccountName, Title | Export-Csv -Path C:\Users\admin\Desktop\test.csv -notype -Append
$web.Dispose()

It generates a .text.csv file…

But it looks like below.


"Address","Status","AccountName","Title"
,"Manager"
,"Director "
,"John"
,"Smith"
,"Bob"


It only seems to be exporting the Title column for some reason!. And not the address, status or account name?

Any Ideas?

Thanks
by AlexBrassington at 2013-03-27 09:11:25
The property names will be different. Get all the properties for the first item in the array and try to match the internal name of the property to the visible ones you see in the GUI.
by bronyx85 at 2013-03-27 10:25:31
Hi Alex,

$items | Select-Object Address, Status, AccountName, Title | Export-Csv -Path C:\Users\admin\Desktop\test.csv -notype -Append

The script line above… is looking at the Internal Column names. i.e Address, Status, AccountName, Title are the Internal Column Names.

:slight_smile:
by AlexBrassington at 2013-03-27 10:46:42
Title is but since the rest are blank i doubt you have the right property names. Or the way you are accessing them is wrong.
by bronyx85 at 2013-03-28 02:17:20
Hi Alex,

Ok, so the way I am finding the internal column name is by going into the list settings, and right clicking the field (AccountName, Status etc…) , selecting properties, and I am presented with the following :

FldEditEx.aspx?List=%7BFC54C995%2D0367%2D46D2%2D875B%2D0FB82E72FC68%7D&Field=AccountName

Where Field is the Internal AccountName…

I thought that was the way to find the internal column name of a column… Or I am wrong?

Many thanks