#variables
$location = 'C:\User_Photos'
#settings
$Dir = get-childitem $location
$List = $Dir | where {$_.extension -eq ".jpg"}
#loop all JPG's
foreach ($item in $List)
{
$filename = $item.Name
$username = $filename.split('\.')[-2]
$Picture=[System.IO.File]::ReadAllBytes("$location\$filename")
write-host "Found photo $location\$filename"
write-host "Processing $username"
#Populate AD
write-host "Adding photo to AD for $username"
SET-ADUser $username –add @{thumbnailphoto=$Picture}
#Populate Office365
write-host "Adding photo to Office365 for $username"
Set-UserPhoto $username -PictureData ([System.IO.File]::ReadAllBytes("$location\$filename")) -Confirm:$Y
}
All photos are 96 x 96 pixels, JPG format and <10KB in size.
$location = 'C:\User_Photos'
#settings
$Dir = get-childitem $location
$List = $Dir | where {$_.extension -eq ".jpg"}
#loop all JPG's
foreach ($item in $List)
{
$filename = $item.Name
$username = $filename.split('\.')[-2]
$Picture=[System.IO.File]::ReadAllBytes("$location\$filename")
write-host "Found photo $location\$filename"
write-host "Processing $username"
#Populate AD
write-host "Adding photo to AD for $username"
SET-ADUser $username –add @{thumbnailphoto=$Picture}
#Populate Office365
write-host "Adding photo to Office365 for $username"
Set-UserPhoto $username -PictureData ([System.IO.File]::ReadAllBytes("$location\$filename")) -Confirm:$Y
}
All photos are 96 x 96 pixels, JPG format and <10KB in size.