AD

[PowerShell] Export AD photo

Here is a PowerShell to export AD photo, please make sure you have the rights to do so before running the script. The script will prompt for the username and it will be saved as “username.jpg” under the path specify in $path variable.

 

$username = Read-Host 'Please enter Username'

$path = 'C:\Photos\'

$User=GET-ADUser $username –properties thumbnailphoto

$Filename=$path+$username+'.jpg'

[System.Io.File]::WriteAllBytes($Filename, $User.Thumbnailphoto)