Solved

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

Posted on 2016-10-09
5
30 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 28

Assisted Solution

by:Pawan Kumar
Pawan Kumar 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 17

Expert Comment

by:Walter Curtis
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 17

Expert Comment

by:Walter Curtis
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Pimping Sharepoint 2007 without Server-Side Code Part 1 One of my biggest frustrations with Sharepoint 2007 in the corporate world is that while good-intentioned managers lock down the more interesting capabilities of Sharepoint programming in…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

726 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