powershell script with list view

Hi,

I have a scheduled job in SharePoint 2013 environment, where I export SharePoint list Items as csv. I would like to use a SharePoint list View so that I get all the items from the view into csv. I tried below script and it only returns items that are in the first paginated view. The view has an item limit of 50 items. But I wan't to return all the items in the view. 

Please help me modify the script accordingly. Thank you.

#Retrieving the Web Site with List

$MyWeb = Get-SPWeb "http://mysite/sites/testsite"

#Get the List name
$MyList = $MyWeb.Lists["Programs"]

#Get The View
#Change the name of the view
$MyView = $MyList.Views["My View"]

#Get the Items from the view
$MyItems = $MyList.GetItems($MyView)

#Get Specific field items and export it to a csv file
$MyItems | %{ select-object -input $_ -prop @{Name='ID';expression={$_.ID;}}, 
@{Name='Content Type';expression={$_["P. Type"];}}, 
@{Name='Program Name';expression={$_["Program Name"];}},
@{Name='Classifications';expression={($_["Classifications"]).substring(($_

["Classifications"]).IndexOf("#")+1);}},
@{Name='Classifications ID';expression={($_["Classifications"]).split(";")[0];}},
@{Name='VP';expression={($_["VP Owner"]).substring(($_["VP Owner"]).IndexOf("#")+1);}},
@{Name='VP ID';expression={($_["VP Owner"]).split(";")[0];}},
@{Name='Project Manager';expression={$_["Project Manager"];}},
@{Name='GL Project Code';expression={$_["GL Project Code"];}}, 
@{Name='Segment BU';expression={($_["Segment BU"]).substring(($_["Segment BU"]).IndexOf

("#")+1);}}, 
@{Name='Segment BU ID';expression={($_["Segment BU"]).split(";")[0];}},
@{Name='C-Product Line';expression={$_["C-Product Line"];}}, 
@{Name='Node and Foundry';expression={($_["Node and Foundry"]).substring(($_["Node and 

Foundry"]).IndexOf("#")+1);}},
@{Name='Node and Foundry ID';expression={($_["Node and Foundry"]).split(";")[0];}},
@{Name='Phase';expression={$_["Phase"];}}, 
@{Name='Program Activity';expression={$_["Program Activity"];}}, 
@{Name='Archive';expression={$_["Archive"];}}; } | Export-Csv -Path "c:\Dashboard.csv"

   &n
January 31st, 2015 3:51am

hi

another approach

instead of a view, use the list, as it is,order it, parse it and export items to a csv file

Here is an example how to order it

http://www.sharepointdiary.com/2013/04/export-sharepoint-list-items-to-csv-using-powershell.ht

January 31st, 2015 10:38am

Hi CoolTechie,

Rather than writing a batch job to populate excel timely fashion, I will suggest to make a excel data source auto-refresh after every minute, which is more real time. That excel can be shared as well.

You can use the Excel as external data source, you can set refresh the excel per 1 minute.

The steps of configuration, you can refer to the following link.

http://sharepointlink.blogspot.com/2010/08/sharepoint-2010-excel-services-and.html

January 31st, 2015 12:06pm

try this link:

http://www.sharepointdiary.com/2013/04/export-sharepoint-list-items-to-csv-using-powershell.html

http://blogs.msdn.com/b/kaevans/archive/2012/02/13/iterating-large-sharepoint-lists-with-powershell.aspx

http://spdeva.blogspot.in/2014/09/sharepoint-large-list-pagination.html

http://sharepointblogbyshri.blogspot.in/2013/10/sharepoint-2010-edit-pagination-size.html

http://www.jbmurphy.com/2012/04/04/powershell-to-get-all-items-in-a-sharepoint-2007-list-via-web-servicessoap/

--------------------------------------------------------------------------------------------------------------------------------------

Please mark answer as correct if it is correct else vote for it if you find it useful Happy SharePointing

Free Windows Admin Tool Kit Click here and download it now
February 2nd, 2015 2:42am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics