How to Determine Which SharePoint Users Have a Profile Picture

I recently needed a means of getting a list of all users who had a profile picture associated with their SharePoint account (well, the client was actually more interested in knowing who didn’t have a profile picture, but this result below worked for them). Below is a simple PowerShell script for being able to get a list of the user names, and the URL of their profile picture (if they had one). In the case of users who did not have a profile picture, their “PictureURL” value was empty, and these were ultimately the values the client was after (to encourage all users to upload a profile picture).


# Change your URL below
$spsite = new-object Microsoft.SharePoint.SPSite(“https://[]“);
$spsc = [Microsoft.SharePoint.SPServiceContext]::GetContext($spsite);
$sppm = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($spsc)
$profiles = $sppm.GetEnumerator()

write-host “Display Name ; Account Pic”

foreach ($profile in $profiles)
    $DisplayName = $profile.DisplayName    
    $AccountPic = $profile[[Microsoft.Office.Server.UserProfiles.PropertyConstants]::PictureURL].Value

    if ($AccountPic -ne “” -AND $AccountPic -ne ” ” -AND $AccountPic -ne $NULL)
        write-host $DisplayName, “; [“, $AccountPic, “];”