Solved

Get list of Sharepoint users who do not have a mysite photo

Posted on 2016-10-09
5
20 Views
Last Modified: 2016-10-17
Hi,
We have a Sharepoint 2010 Enterprise Intranet, each user has a mysite profile, however not all users have photos on their mysite pages. How would I return a list of users who do not have photos on their Mysite profile? Is this trickier than it sounds ?

Ideally I would like to generate a CSV file of users who do not have a photo which could then be used in a seperate script to add a photo from an web based internal employee directory (not unlike the process mentioned in https://blogs.msdn.microsoft.com/pranab/2011/08/26/sharepoint-2010-import-user-profile-photos-from-file-system/).
Many thanks for any help
0
Comment
Question by:uuccu
  • 2
  • 2
5 Comments
 
LVL 17

Assisted Solution

by:Pawan Kumar Khowal
Pawan Kumar Khowal earned 500 total points
ID: 41835842
May be this you are looking for...

You can create a sample C# console program to get the information.
//Get Picture info for a user

--
SpWeb SharepointWeb = new SPSite("http://Pawan.com").OpenWeb(); 
SPUser userInfo = SharepointWeb.EnsureUser(@"Pawan");
SPListItem usersList = userInfoList.Items.GetItemById(userInfo.ID);  
string Isimage = usersList["Picture"].ToString(); 

If (IsImage.ISNULLorEmpty())
{
   ....................Perform your operation // /Pawan

}

--

Open in new window


If you need it for all users then use like

--

SPList userInfoCollection = SharepointWeb.SiteUserInfoList;
foreach ( SPListItem userInlist IN userInfoCollection.Items )
{
	.......

}
--

Open in new window


Hope it helps.

MS URL if you need more help - https://social.msdn.microsoft.com/Forums/sharepoint/en-US/8e3971e0-c38e-4f6b-9b5f-3a52d60dff67/siteuserinfolist-default-columns?forum=sharepointdevelopmentprevious
0
 
LVL 14

Expert Comment

by:SneekCo
ID: 41835959
Just an idea, instead of determining who does not have a photo and then making a custom script to upload those missing photos, just run a script to upload to all my sites. That way the my sites always have the most current photos. Less effort, more results...

Hope that helps...
0
 
LVL 14

Expert Comment

by:SneekCo
ID: 41838890
Any luck?
0
 

Accepted Solution

by:
uuccu earned 0 total points
ID: 41840915
Hi,
I pieced together some powershell code that gives me what I need thanks, something like this...

$url = "http://site"
$site = Get-SPSite $url
$context1 = Get-SPServiceContext $site

# Create Object for main loop to check for missing photos
$userProfileManagerLoopAllUsers = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context1)


#Loop through all UPS User accounts to find an account with a missing photo
$profilesList = $userProfileManagerLoopAllUsers.GetEnumerator()

foreach($userProfile in $profilesList){
# populate variables for each user account
 
  $name = $userProfile["PreferredName"]
  $omniausername = $userProfile["userName"].value
  $omniaaccusername = $userProfile["AccountName"].value
  $PicURL = $userProfile["PictureURL"].value
 

  # test picurl property to write out list of accounts to be updated and their picurl properties
 
    if ($PicURL -eq $null)
  {
    Write-Host "Account does not have Picture URL:"
      Write-Host ""
    Write-Host ("Name:                                     " + $name)
    Write-Host ("Omnia Username:                           " + $omniausername)
    Write-Host ("Omnia Account Username:                   " + $omniaaccusername)       
      Write-Host ("Picture URL:                              " + $PicURL)
 }
}
0
 

Author Closing Comment

by:uuccu
ID: 41846342
The solution i came up with met my needs much better than the suggested solutions
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Work Over Net is a new and very powerful collaboration product. With its new easy interface it is becoming very competitive to other similar products like webex and office interactive. WON 2010 have the standard business tools needed for multi-offic…
There is one common problem that all we SharePoint developers share: custom solution deployment. This topic can't be covered fully in this short article, so all I want to do in this one is to review it from a development-to-operations perspectiv…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now