ps-userprofileexport

Title: Export User Profile Information to Excel

Description: Export the user profile information to Excell.



  1. # -----------------------------------------------------------------------------  
  2. # Script    : To Export User Profile Information Value in Excel and HTML  
  3.   
  4. #. Use Internal name of the user profile property.  
  5. #. Any custom user fields will have "SPS-".  
  6. #. Remove comment "#" in line 43 and do the same in line 48 if you need HTML output.  
  7. #. Provide location after out-file to save the HTML file.  
  8. #. In Line 59 use the same location as Out-File.  
  9. #. Append if you have any custom fields in mysite user profile property  
  10. #. For HTML look and feel please copy and paste the style.css in C:\.  
  11. #. Use any style.css as per organization standard and policy.  
  12.   
  13. Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue  
  14.   
  15. $siteUrl = "http://people.in.lakku.com"  
  16. $outputFile = "E:\Temp\ProfileCount.csv"  
  17.   
  18. $serviceContext = Get-SPServiceContext -Site $siteUrl  
  19. $profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($serviceContext);  
  20. $profiles = $profileManager.GetEnumerator()  
  21.   
  22. $collection = @()  
  23. foreach ($profile in $profiles) {  
  24. $profileData = "" |  
  25. select "AccountName","PreferredName" , "TimeZone""Birthday" , "AlternateEmail" , "AltMobile" , "SkypeName" , "HomePhone" , "Assistant" , "VoluntaryPositions" , "AssociationMemberships" , "PreviousEmployers" , "EducationHistory" , "Yammer" , "FaceBook" , "LinkedIn" , "Twitter" , "GooglePlus" , "YahooPulse" , "FourSquare" , "PhoneticName""AskMe" , "Responsibilities" , "Manager" , "Interests" , "PastProjects" , "Skills" , "AboutMe" , "PreviousRolesAt"  
  26. $profileData.AccountName = $profile["AccountName"]  
  27. $profileData.PreferredName = $profile["PreferredName"]  
  28. $profileData.TimeZone = $profile["SPS-TimeZone"]  
  29. $profileData.Birthday = $profile["SPS-Birthday"]  
  30. $profileData.AlternateEmail = $profile["AlternateEmail"]  
  31. $profileData.AltMobile = $profile["AltMobile"]  
  32. $profileData.SkypeName = $profile["SkypeName"]  
  33. $profileData.HomePhone = $profile["HomePhone"]  
  34. $profileData.Assistant = $profile["Assistant"]  
  35. $profileData.VoluntaryPositions = $profile["VoluntaryPositions"]  
  36. $profileData.AssociationMemberships = $profile["AssociationMemberships"]  
  37. $profileData.PreviousEmployers = $profile["PreviousEmployers"]  
  38. $profileData.EducationHistory = $profile["EducationHistory"]  
  39. $profileData.Yammer = $profile["Yammer"]  
  40. $profileData.FaceBook = $profile["FaceBook"]  
  41. $profileData.LinkedIn = $profile["LinkedIn"]  
  42. $profileData.Twitter = $profile["Twitter"]  
  43. $profileData.GooglePlus = $profile["GooglePlus"]  
  44. $profileData.YahooPulse = $profile["YahooPulse"]  
  45. $profileData.Twitter = $profile["FourSquare"]  
  46. $profileData.PhoneticName = $profile["PhoneticName"]  
  47. $profileData.AskMe = $profile["SPS-Responsibility"]  
  48. $profileData.Responsibilities = $profile["Responsibilities"]  
  49. $profileData.Manager = $profile["Manager"]  
  50. $profileData.Interests = $profile["SPS-Interests"]  
  51. $profileData.PastProjects = $profile["SPS-PastProjects"]  
  52. $profileData.Skills = $profile["SPS-Skills"]  
  53. $profileData.AboutMe = $profile["AboutMe"].Value  
  54. $profileData.PreviousRolesAt = $profile["PreviousRolesAt"]  
  55. #$collection += $profileData | ConvertTo-Html -Fragment  
  56. $collection += $profileData  
  57. }  
  58.   
  59. #ConvertTo-Html -Body "$collection" -CssUri C:\style.CSS | Out-File "Location to save"  
  60.   
  61. $collection | Export-Csv $outputFile -NoTypeInformation  
  62.   
  63. #Send Mail to Box for easy access  
  64. #$SMTP = "Name of the SMTP Server"  
  65. #$From = "Email Address"  
  66. #$To = "Email Address" , "Email Address"  
  67. #$Subject = "User Profile Information Report"  
  68. #Send-MailMessage -From $From -To $To -SmtpServer $SMTP -Subject $Subject -Attachments "Same as Out-File Location"