Instantly share code, notes, and snippets.

Embed
What would you like to do?
Adding Multiple or Individual Photos to the GAL
<#
######
IMPORT PHOTOS EN-MASSE BASED ON THE PHOTOS BEING NAMED AFTER THE RELEVANT USERS
e.g. for staff members Alan Alanson, Barry Barryson, Charles Charleson,
the photos would need to be name "Alan Alanson.jpg", "Barry Barryson.jpg", "Charles Charleson.jpg".
#####
#>
$PhotoPath = "\\SERVER\SHARE\photos\Outlook\*.*"
ForEach ($PhotoFile in gci $PhotoPath)
{
$User = '' + $PhotoFile.Name.substring(0, $PhotoFile.Name.Length - 4) + ''
<#
#####
YOU CAN USE THE BELOW LINE TO DELETE ALL USER PHOTOS
Set-Mailbox "$user" -RemovePicture
######
#>
Import-RecipientDataProperty -Identity $User -Picture -FileData ([Byte[]]$(Get-Content -Path $PhotoFile.Fullname -Encoding Byte -ReadCount 0))
}
<#
#####
This is the code to import a single photo for a specific user
#####
#>
Import-RecipientDataProperty -Identity "Alan Alanson" -Picture -FileData ([Byte[]]$(Get-Content -Path "\\SERVER\SHARE\photos\Outlook\Alan Aanson.jpg" -Encoding Byte -ReadCount 0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment