Tuesday, March 4, 2014

Exporting User Profiles Property in Sharepoint 2010 into excel


((Reference: http://csefi.blogspot.com/2012/02/sharepoint-2010-user-profile-export-to.html))

Don't you often hear the question from users: "How can I export the user profile to excel?" Many clients use the SharePoint user profile to synchronize user data from diffent directory services into SharePoint so everyone can find all the necessary information at one place. The only thing that customers miss is the built in functionality to export all the user information.

I've written a small application which has four functionalities:
  • Connect User Profile and list the properties and their types
  • Export user profiles into CSV with the selected user profile properties
  • Generate powershell script to export user profiles into CSV with the selected properties
  • List user's properties 
I hope you find the application helpfull.

You can download the application from here.
and...
you can download the source code from here.

Cheers,
Cséfi

Afterwords
This blog is not intend to explain how you can work with user profile store, because there are many blogs already about this topic. Just bing for it. In nutshell there are three ways how you can work with user profiles. You can use powershell script or object model to get the required data.
Object model

By adding Microsoft.Office.Server.UserProfiles.dll to your project, you will be able to use UserProfileManager class and get all the information you need. There are many blogs that explain how to use these classes so I'm not going to do it agian.

Web service

SharePoint 2010 has a built in user profile webservice. You just need to add as a Web reference to your project. The URL of the webservice is: http://yourserver/_vti_bin/userprofileservice.asmx
After you've added the reference to your project you will have a UserProfileService proxy class and you will be able to do all kind of things just as with object model, like getting User Profile properties, user profiles, etc.

Powershell script

You can do almost everything with Powershell scripts and it is not different when it comes to user profiles. Here is a little example to get user profiles  from User Profile:

$serviceContext = Get-SPServiceContext -Site http://server
$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($serviceContext);
$profiles = $profileManager.GetEnumerator()
foreach($userProfile in $profiles)
{
 #Do something
 #$propertyName = "Title"
 #Write-Host $userProfile[$propertyName];

}

No comments:

Post a Comment

Thank you, we will reply soon.