SharePoint Online: Export User Information List using PowerShell

Requirement: Export User Information List in SharePoint Online

User Information List in SharePoint Online stores the information about users. It captures user metadata such as User Picture, Email, DisplayName, LoginName, etc. When we grant permissions to a user, they are added automatically to the hidden User Information list. SharePoint retrieves user-related metadata for fields such as Created By,  last modified, etc. from the User Information List.

PowerShell to Export User Information List in SharePoint Online

This PowerShell script exports all user information to a CSV file from the user information list of any SharePoint Online site collection.

#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

$CSVPath = "C:\Temp\UserInfo.csv"

#Get Credentials to connect
$Cred= Get-Credential

Try {
    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)

    #Get the User Information List
    $FieldColl = $List.Fields
    #Get All Items from User Information List
    $ListItems = $List.GetItems([Microsoft.SharePoint.Client.CamlQuery]::CreateAllItemsQuery())

    #Array to Hold Result - PSObjects
    $ListItemCollection = @()
    #Fetch each list item value to export to excel
    ForEach($Item in $ListItems)
        $ExportItem = New-Object PSObject 
        ForEach($Field in $FieldColl)
            $ExportItem | Add-Member -MemberType NoteProperty -name $Field.InternalName -value $Item[$Field.InternalName]   
        #Add the object with property to an Array
        $ListItemCollection += $ExportItem
    #Export data to CSV File
    $ListItemCollection | Export-Csv -Path $CSVPath -NoTypeInformation -Force

    Write-host "User Information List has been Exported to CSV!'" -f Green
Catch {
    write-host -f Red "Error:" $_.Exception.Message

This script generates below CSV file (I’ve removed some of the columns from the CSV, BTW!)

export user information list sharepoint online

Export User Data from User Information List using SharePoint Online Management Shell:

SharePoint Online Management Shell has a cmdlet Export-SPOUserInfo to export user data from the user information list. 

#Connect to SharePoint Online
Connect-SPOService -Url

#Export User Info
Export-SPOUserInfo -LoginName [email protected] -site -OutputFolder "C:\Temp"

Here is another post for SharePoint On-premises: How to Export User Information List in SharePoint?

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

Leave a Reply