Export SharePoint 2013 User Profile Information Values In CSV Using PowerShell

When you create site settings you need a user profile service application to sync with the data base to retrieve the audience settings and profile details.

Here I will quickly explain about how to configure the User profile application through the UI method,

Goto SharePoint 2013 Central Admin-->Application Management-->Manage Service Applications-->Service Applications tab to enable the ribbon--> Create a UPSA.

Here we will see about the Powershell method. It is a very simple one to create for admins.

GET ALL User profile properties

Syntax
  1. # -----------------------------------------------------------------------------   
  2. # Script    :Export User Profile Information Value in CSV  
  3. # Author    : Gowtham Rajamanickam  
  4. # Date      : February 12 2017  
  5. # Version   :1.0   
  6. # -----------------------------------------------------------------------------   
  7.  Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue   
  8.    
  9. $siteUrl = "https://gowtham.sharepoint.com"   
  10. $outputFile = "D:/sharepoint/Documents"    
  11. $Context = Get-SPServiceContext -Site $siteUrl   
  12. $userprofileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($Context);   
  13. $Userprofiles = $userprofileManager.GetEnumerator()   
  14.    
  15. $collection = @()   
  16. foreach ($Userprofile in $Userprofiles) {   
  17.     
  18.    $profileProperty = "" |    
  19.    select "FirstName""LastName",  "AccountName""PreferredName" , "Department" , "Manager" , "Office" , "Location" , "WorkEmail" , "Assistant" , "AboutMe" , "Language" ,"Role"   
  20.    $profileProperty.AccountName = $profile["FirstName"]   
  21.    $profileProperty.AccountName = $profile["LastName"]   
  22.    $profileProperty.AccountName = $profile["AccountName"]   
  23.    $profileProperty.PreferredName = $profile["PreferredName"]   
  24.    $profileProperty.Manager = $profile["Manager"]   
  25.    $profileProperty.Department = $profile["Department"]   
  26.    $profileProperty.Office = $profile["Office"]   
  27.    $profileProperty.Location = $profile["Location"]   
  28.    $profileProperty.WorkEmail = $profile["WorkEmail"]   
  29.    $profileProperty.Assistant = $profile["Assistant"]   
  30.    $profileProperty.AboutMe = $profile["AboutMe"].Value   
  31.    $profileProperty.Language = $profile["Language"]   
  32.    $profileProperty.Role = $profile["Role"]       
  33.    $collection += $profileProperty   
  34. }   
  35. $collection | Export-Csv $outputFile -.csv   
  36.    
Thanks for reading my blog.
Ebook Download
View all
Learn
View all