PowerShell Script to export SharePoint List in Excel File - SharePoint Tutorial

In this blog, I will write about "Export SharePoint list items using PowerShell Script".
To implement this task follow below steps -

1. Create a folder with the name  "Test" in drive C:
2. Create a SharePoint List with name "EmpList"
3. EmpList should contain 4 columns - ID, Title, EmpName, Department

5. Write below script in a notepad or any editor and save this file as .ps1, .ps1 is the file extension of Powershell Script.

Change the SharePoint site url with your running SharePoint site url and execute the script.

PowerShell Script to Export SharePoint List Items in Excel 

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Get the SPWeb
$web = Get-SPWeb -identity "<sharepoint site url>"

#Get the SPList
$list = $web.Lists["EmpList"]
$ListItemCollection = @()

 $list.Items | foreach {
 $ExportItem = New-Object PSObject
 $ExportItem | Add-Member -MemberType NoteProperty -name "ID" -value $_["ID"]
 $ExportItem | Add-Member -MemberType NoteProperty -name "Title" -value $_["Title"]
 $ExportItem | Add-Member -MemberType NoteProperty -name "EmpName" -value $_["EmpName"]
 $ExportItem | Add-Member -MemberType NoteProperty -name "Department" -value $_["Department"]
 $ListItemCollection += $ExportItem

Write-Host "Copying data from list to Excel"
$ListItemCollection | Export-CSV "C:\Test\MyList.csv"                   
#Dispose the web Object

You may like this - Get data from SharePoint list and store in SQL Table - C# Code

You may read some popular blogs on SharePointCafe.Net

Keep following SharePointCafe.Net for upcoming blogs.


  1. PowerShell Script to Export SharePoint List items in excel however your code says csv


Post a Comment

Dear Readers, Please post your valuable feedback in the comment section if you like this blog or if you have any suggestions. I would love to hear the same from you. Thanks