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 🙂 !
HI Dipti,Thanks for your time on sharepoint community.You can see me below
http://expertsharepoint.blogspot.de
nice script …THanks alot Dipti ..Happy ShareePointing……