I have a requirement where I need to get a user from User Profile Store in SharePoint but the only thing I have available is Email. This field is unique in HR system.

How can I pull user just by email? One option I thought was with Query but then I have 8000 plus users and that might take a while to run.

Looking for a way to do this in a efficient way. Any help is highly appreciated!!


2 Answers 2


Try this;

Add-PSSnapin "Microsoft.SharePoint.PowerShell"
$site = Get-SpSite $mySitesURL;
$context = Get-SPServiceContext $site;
$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)
$allProfiles = $profileManager.GetEnumerator()
foreach ($profile in $allProfiles) {
   if ($profile.GetProfileValueCollection("WorkEmail") -eq $emailAddress) {

This will return you a user profile object (Microsoft.Office.Server.UserProfiles.UserProfile) for the email address you have queried.

  • I have feed which has 8000+ users with email address. With your solution I have to loop all the users every time to find a single match. I need something that can kind of do a lookup in UPS and pull the user. Thanks for your help!
    – Kauser
    Sep 27, 2016 at 19:47
  • You could query the database, querying our own MySites DB, the two columns you would be looking for are tp_Title and tp_Email Sep 28, 2016 at 7:49

From what I've experienced, you can't directly fetch user profiles w/out the user login. Assuming you're fetching user profiles using the following code, there's two potential approaches I'd take if you only had email addresses.

$site = Get-SPSite https://root
$context = Get-SPServiceContext $site
$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)
$userProfile = $profileManager.GetUserProfile("domain\username")


  1. Use AD PowerShell to get the user account and from there you can get their user login.

You should be able to install AD's PowerShell module if it's not already available. Then run the following to get their account:

$user = Get-ADUser -Filter {EmailAddress -eq "[email protected]"} -Properties *

You should then be able to construct their user login:

$userLogin = "domain\" + $user.SamAccountName
  1. Fetch the user from My Site's "User Information List", then construct their user login.


$web = Get-SPWeb https://mysite
$user = $web.Lists["User Information List"].Items | where{$_["EMail"] -eq "[email protected]"}

You should then be able to construct their user login:

$userLogin = "domain\" + $user["UserName"]

I'm sure there's other potential ways to do this as well, but hopefully one of those proves sufficient.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.