PowerShell script to export User Information List
There are several sources online providing script sample to export user list. However none of them can export user details (e.g. Login, email, and to distinguish between user and group). The login information is very important when your SharePoint is riding on multiple domain environment. You can have domainA\admin & domainB\admin at the same time while both Display Name is “Admin”.
User Information List is a hidden list per each site collection. Whenever the user or group take any action to the site collection, the user’s information will be added to the list. Also note that even the user have been deleted from Active Directory, his name will remain in the list. The list is helpful to estimate the site usage for license estimation.
Here is the script.
$SiteUrl=”http://sharepoint.com"
$OutPutFile = “E:\report\UserInfoList.csv”
$web = Get-SPWeb $siteUrl
$UserInfoList = $web.SiteUserInfoList$ListItemCollection = @()
foreach ($item in $UserInfoList.Items){
$ExportItem = New-Object PSObject
$ExportItem | Add-Member -MemberType NoteProperty -name “User Name” -value $item.Name
$xml = [xml]$item.xml
$ExportItem | Add-Member -MemberType NoteProperty -name “Title” -value $xml.row.ows_Title
$ExportItem | Add-Member -MemberType NoteProperty -name “Login” -value $xml.row.ows_Name
$ExportItem | Add-Member -MemberType NoteProperty -name “Email” -value $xml.row.ows_EMail
$ExportItem | Add-Member -MemberType NoteProperty -name “Department” -value $xml.row.ows_Department
$ExportItem | Add-Member -MemberType NoteProperty -name “JobTitle” -value $xml.row.ows_JobTitle
$ExportItem | Add-Member -MemberType NoteProperty -name “ContentType” -value $xml.row.ows_ContentType
$ListItemCollection += $ExportItem
}$ListItemCollection | Export-CSV $OutPutFile -NoTypeInformation
Write-host “User Information List Exported to $($OutputFile) for site $($SiteURL)”$web.Dispose()
Originally published at http://createsitecollection.wordpress.com on September 6, 2019.