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”

$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 passionate and ambitious SharePoint & Office 365 specialist, including technologies that are or will be directly interacting with SharePoint technology stack. She currently holds a position of manager as SharePoint/Office 365 Architect in Capgemini, Mumbai.

Leave a Reply

2 Comment threads
0 Thread replies
Most reacted comment
Hottest comment thread
2 Comment authors
GauravAnil Avula Recent comment authors
newest oldest most voted
Notify of
Anil Avula

HI Dipti,Thanks for your time on sharepoint community.You can see me below


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

Social Media Integration by Acurax Wordpress Developers
Visit Us On TwitterVisit Us On FacebookVisit Us On LinkedinVisit Us On Instagram