[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)

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s