Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Azure Active Directory Photo Sync to Microsoft Identity Manager. Supporing blog post is located here
# Photos
if ($user.'thumbnailPhoto@odata.mediaContentType'){
try {
# Get the users profile photo
$url = ""+($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
# Checksum
[string]$imgchecksum = $byteImg | Get-Hash -Algorithm SHA256
$obj.add("AADPhotoChecksum", $imgchecksum)
"Photo Checksum " + $imgchecksum | Out-File $DebugFile -Append
"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