[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 41
  • Last Modified:

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

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
uuccu
Asked:
uuccu
  • 2
  • 2
2 Solutions
 
Pawan KumarDatabase ExpertCommented:
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
 
Walter CurtisSharePoint AEDCommented:
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
 
Walter CurtisSharePoint AEDCommented:
Any luck?
0
 
uuccuAuthor Commented:
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
 
uuccuAuthor Commented:
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!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now