Solved

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

Posted on 2016-10-09
5
34 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 29

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 18

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 18

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

I used to be SharePoint evangelist in our company, so my Outlook always full of questions about how to do this, or where I can find that. One day I found such an email with the following question: "how to attach 3-State workflow (one of the workflow…
In case you ever have to remove a faulty web part from a page , add the following to the end of the page url ?contents=1
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

690 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