Export User Information Per Synchronization Connection in SharePoint 2010

Hello SharePointer :) !

Today, I am going to post the script which will help to export user information per synchronization connection.

As we know, SharePoint doesn’t provide users count per synchronization connection.Instead you see total user count available in UPS.After searching  and querying at  FIM and UPA database, I couldn’t find the exact user count as I required.At last, I have received convincible automated script written by one of my friends  Chen at here

I have filtered the script per domain name and I have received the result as I was looking for :) !

 

Following is the script you require to run on SharePoint Server :

# ———————————————————————————–
# Script : Export User Profile Information Per Synchronization connection in Excel
# Author : Dipti Chhatrapati
# ————————————————————————————

#Add SharePoint snap in

if ((Get-PSSnapin “Microsoft.SharePoint.PowerShell” -ErrorAction SilentlyContinue) -eq $null) {
Add-PSSnapin “Microsoft.SharePoint.PowerShell”
}

#Declaration
$siteUrl = “http://mysite-host-url/”
$userCollection = @()

#Get User Data
$domain=Read-Host “Enter Domain Netbios Name:”
$outputFile=Read-Host “Enter CSV File Location:”
$OutputFile = $outputFile + “\” + $domain + “_TotalUsers.csv”

# Get User Profile Context
$serviceContext = Get-SPServiceContext -Site $siteUrl
$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($serviceContext);
$profiles = $profileManager.GetEnumerator()

Write-Host Getting Users…

#Iterate through Profiles
foreach ($profile in $profiles)
{
#Define Profile Data
$userData = “” | select “AccountName”,”PreferredName”,”Department”,”Office”,”Location”,”WorkEmail”,”Role”

#Get Domain Name
$string = $profile[“AccountName”].ToString().Split(‘\’)[0]

#Extract user If domain name matches
if ($domain -contains $string)
{
$userData.AccountName = $profile[“AccountName”]
$userData.PreferredName = $profile[“PreferredName”]
$userData.Department = $profile[“Department”]
$userData.Office = $profile[“Office”]
$userData.Location = $profile[“Location”]
$userData.WorkEmail = $profile[“WorkEmail”]
$userData.Role = $profile[“Role”]
$userCollection += $userData
}
}

#Export user data to CSV File
$userCollection | Export-Csv $OutputFile -NoTypeInformation

#Get User Count of entered domain name
Write-Host Total user count of $domain domain is $userCollection.Length

Above script is downloadable from technet gallery at here.

Happy SharePointing :) !

Dipti Chhatrapati

Dipti Chhatrapati is a SharePoint specialist currently working as a Senior Consultant for CapGemini in Mumbai, India. She has more than 9 years of experience in application development, design, maintenance, administration and is continuously working with improving her skills and keeping them up to date. As a developer, project leader and SharePoint Business Analyst, she has been an extensive user of Visual Studio and Team Foundation Server throughout her career. Dipti is very passionate about music, sports, and arts and loves to spend her free time learning new things, socializing with friends and family, cooking, exercising and singing.

Leave a Reply

2 Comments on "Export User Information Per Synchronization Connection in SharePoint 2010"

Notify of
avatar
Sort by:   newest | oldest | most voted
Anil Avula
Guest

HI Dipti,Thanks for your time on sharepoint community.You can see me below
http://expertsharepoint.blogspot.de

Gaurav
Guest

nice script …THanks alot Dipti ..Happy ShareePointing……

wpDiscuz