I am attempting to dump all data from my Sharepoint Lists to csv. I seem to have the code working at about 95% the way I want it, but I am missing the Created By, Created On, Modified By, and Modified On dates. How do I capture those fields?
Here is my current code for one of my lists:
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
$url = "http://internalweburl/subsite"
$listName = "List1"
$path ="c:\Exports\$listname.csv"
$web = Get-SPWeb $url
$list = $web.Lists.TryGetList($listName)
$fields = $list.ContentTypes | %{ $_.FieldLinks } | select Name, DisplayName
$items = @() #array to store objects representing list items
$list.items | %{
$item = $_;
$hash = @{}; #hash table to store field name-value pairs
$fields | %{ $hash[$_.DisplayName] = $item[$_.Name] };
$items += new-object psobject -Property $hash }
$items | Export-Csv -Path $path
Without having to list each individual field, I can't seem to find a way to include those. This would be a huge undertaking as we have many lists I need to export, and I don't have the time to go through each and document all the fields. Any help would be greatly appreciated.