export to excel with powershell from sharepoint list

sns 9,226 Reputation points
2021-01-25T10:21:34.913+00:00

Hi,

Do we have any PowerShell script which export to excel from list. Need it for 2010 and 2016. Please help

SharePoint Server Management
SharePoint Server Management
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Management: The act or process of organizing, handling, directing or controlling something.
2,846 questions
0 comments No comments
{count} votes

Accepted answer
  1. Li Zhang_MSFT 1,566 Reputation points
    2021-01-26T06:58:01.77+00:00

    Hi @sns ,

    Try following PowerShell in SharePoint Management Shell:

    Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue   
       
    #Get the Web   
    $web = Get-SPWeb -identity "http://SiteURL"   
       
    #Get the Target List   
    $list = $web.Lists["ListName"]   
       
    #Array to Hold Result - PSObjects   
    $ListItemCollection = @()   
       
    #Get All List items by specifying fields   
    $list.Items | foreach {   
    $ExportItem = New-Object PSObject   
    #Specify fields   
    $ExportItem | Add-Member -MemberType NoteProperty -name "Title" -value $_["Title"]   
    $ExportItem | Add-Member -MemberType NoteProperty -name "Text" -value $_["Text"]   
       
    #Add the object with property to an Array   
    $ListItemCollection += $ExportItem   
    }   
    #Export the result Array to CSV file   
    $ListItemCollection | Export-CSV "C:\ListData.csv" -NoTypeInformation                          
       
    #Dispose the web Object   
    $web.Dispose()   
    

    Reference:

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

    https://sharepoint.stackexchange.com/questions/103771/how-to-export-powershell-output-to-excel

    Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.

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

    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful