Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Azure Active Directory Photo Sync to Microsoft Identity Manager. Supporing blog post is located here https://blog.darrenjrobinson.com/how-to-synchronize-users-active-directoryazure-active-directory-photo-using-microsoft-identity-manager/
# Photos
if ($user.'thumbnailPhoto@odata.mediaContentType'){
try {
# Get the users profile photo
$url = "https://graph.windows.net/myorganization/users/"+($user.objectId)+"/thumbnailPhoto?api-version=1.6"
$wc = New-Object System.Net.WebClient
$wc.Headers["Authorization"] = $authHeader;
$byteImg = $wc.DownloadData($url)
"User has a photo " + $user.displayName | Out-File $DebugFile -Append
$obj.Add("AADPhoto",$byteImg)
# Checksum
[string]$imgchecksum = $byteImg | Get-Hash -Algorithm SHA256
$obj.add("AADPhotoChecksum", $imgchecksum)
"Photo Checksum " + $imgchecksum | Out-File $DebugFile -Append
}
catch
{
"ERROR: $_.Exception.Message" | Out-File $DebugFile -Append
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.