[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2016-10-09
5
Medium Priority
?
39 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 32

Assisted Solution

by:Pawan Kumar
Pawan Kumar earned 2000 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 20

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 20

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

Technology Partners: 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

When installing SharePoint 2010 RTM I came across a strange error, I was getting timeouts during the installation. I searched the web and found the best solution to be found here (http://social.msdn.microsoft.com/Forums/en-US/sharepoint2010genera…
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…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

656 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