0

I want to retrieve all the user email id, display name, user name & Title from user information list using power shell

1 Answer 1

0

You can use the below PowerShell script:

function ExtractSPuserInformationListToCSV()
{

param
    (
        [Parameter(Mandatory=$true)] [string] $SiteURL

    )

    $web = Get-SPWeb $SiteURL
    $list = $web.Lists["User Information List"]  

    $spQuery = New-Object Microsoft.SharePoint.SPQuery  

    $CamlQueryString = '<Query><OrderBy><FieldRef Name="Title" Ascending="True" /></OrderBy></Query>'  

    $spQuery.Query = $CamlQueryString  

    $userInformationListItemsColls = $list.GetItems($spQuery)  

foreach($oneUserInInformationList in $userInformationListItemsColls) 
{  

    Write-Host $oneUserInInformationList.Title 


    $userData = Get-SPUser -Web $web.URL -Identity $oneUserInInformationList["ows_Name"]

    $UserInformationlistItemData = @{
    "Display Name" = $userData.DisplayName
    "User Login" = $userData.UserLogin
    "Email" = $userData.Email
    "Name" = $userData.Name

}
New-Object PSObject -Property $UserInformationlistItemData


}


$web.Dispose();  
return $UserInformationlistItemData


}


#Call the function like below

ExtractSPuserInformationListToCSV "YourSiteURL" | Export-Csv -NoTypeInformation -Path "Your CSV Path";
1
  • Hi - if it has helped you, could you please [Upvote(^)] and mark as answered. Commented Jun 19, 2020 at 0:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.