Tuesday, July 19, 2016

Find all users who have not added a picture to their Mysite Profile

[void][reflection.assembly]::Loadwithpartialname("Microsoft.Office.Server") | out-null
$site=new-object Microsoft.SharePoint.SPSite("https://peakfinders") #Central Admin site
$servercontext=[Microsoft.Office.Server.ServerContext]::GetContext($site)
$site.Dispose() # clean up
$upm = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($servercontext)
$pc = $upm.GetEnumerator()
foreach($p in $pc){$v = $p["PictureUrl"].Value;if($v -eq $null){Write-Host $p["AccountName"].ToString()"doesn's have a picture set."}}

#Optional, display all the Picture URL's
$pc = $upm.GetEnumerator();
foreach($p in $pc){$p["PictureUrl"].Value}

No comments:

Post a Comment