Professional Documents
Culture Documents
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).
Clear-Host
#Specify tenant admin and URL
$User = 'mack.mcneely@lawsonproducts.com'
$UserProfileOutPut = 'C:\AllProfiles.csv'
$NoProfileOutput = 'C:\UsersWithNoProfile.csv'
Write-Host "Collecting Infomration..." -ForegroundColor Yellow
#i:0#.f|membership|juliani@sharepointmvp.onmicrosoft.com
$PeopleManager = New-Object
Microsoft.SharePoint.Client.UserProfiles.PeopleManager($Context) -ErrorAction
Inquire
Write-Host "Loading People Manager..." -ForegroundColor Yellow
try
{
Connect-MsolService -Credential $Credentials -ErrorAction Inquire
Write-Host "Connected to SharePoint Online Service..." -ForegroundColor Yellow
}
catch
{
Write-Host "Unable to Connect to SharePoint Online...Existing the Script."
return
}
$Headings = ""
$boolCreateHeadings = $true
$NoProfileUsers = @()