Skip to content

Instantly share code, notes, and snippets.

@beaugunderson
Created October 24, 2010 08:40
Show Gist options
  • Select an option

  • Save beaugunderson/643329 to your computer and use it in GitHub Desktop.

Select an option

Save beaugunderson/643329 to your computer and use it in GitHub Desktop.
# I used the following command to generate my images:
# mogrify -resize 96x96 -gravity center -extent 96x96 -format jpg \
# -path outlook -background black -strip -coalesce -quality 95 *.jpg
# Add the Quest AD and Exchange snap-ins
Add-PSSnapin Quest.ActiveRoles.ADManagement -ErrorAction SilentlyContinue
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin -ErrorAction SilentlyContinue
Get-Mailbox -ResultSize Unlimited -RecipientTypeDetails UserMailbox | ForEach {
$username = $_.SamAccountName
If (Test-Path C:\Pictures\$username.jpg) {
Write-Host "Photo found for $username, uploading... " -NoNewLine
$photo = [byte[]](Get-Content C:\Pictures\$username.jpg -Encoding byte)
# Use the Quest AD addons since we don't have 2008 R2 DCs...
#Set-ADUser $username -Replace @{thumbnailPhoto=$photo}
Set-QADUser $username -ObjectAttributes @{thumbnailPhoto=$photo} | Out-Null
Write-Host "[OK]" -ForeGroundColor Green
}
}
Write-Host "Done."
Update-OfflineAddressBook "Default Offline Address Book"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment