Um blog sobre nada

Um conjunto de inutilidades que podem vir a ser úteis

How to capture AD users’ pictures

Posted by Diego em Abril 7, 2015

Tableau offers the possibility of creating visualizations with shapes and provides a few default palettes to be used, which include, arrows, bug tracking, rating, weather among others.
I was building a dashboard to show database usage by user and thought it would be fun to show the user’s picture instead of only its name. In order to do that I thought about taking print screens of all AD’s pictures, which is not really viable if you have more than  a handful of users.
So I started looking for a way to automatically get all the user’s pictures and found that there is something called “Active Directory Administration PowerShell Module” which can be used to achieve the goal.

The module can be found on (Start -> Administrative Tools -> Active Directory Module for Windows Powershell) and is very easy to use.
For example, to display a user’s information just type “Get-ADUser <UserName>”

PS M:\> Get-ADUser <UserName>
DistinguishedName : CN=…\, …,OU=…,OU=…,OU=…,DC=…,DC=…
Enabled           : True
GivenName         : …
Name              : …, …
ObjectClass       : user
SamAccountName    : …
Surname           : …
UserPrincipalName : …@…….


To specifically get the users photo, just add "-Properties thumbnailPhoto":


    PS M:\> $u = GetADUser <UserName> Properties thumbnailPhoto


And to save it:


    PS M:\> $u.thumbnailPhoto | SetContent pic.jpg Encoding byte


In order to run the code to get all users, just use the "Get-ADUser" command and filter by * (this filter can be improved, of course) and wrap your code in a foreach statement:


$users = GetADUser Filter * Properties thumbnailPhoto | ? {$_.thumbnailPhoto}


foreach ($user in $users) {

    $name = $user.SamAccountName + ".jpg" 

    echo $name

    $user.thumbnailPhoto | SetContent $name Encoding byte



Once you have all the pictures, place them on your "My Custom Shapes" folder ("C:\Users\<user>\Documents\My Tableau Repository\Shapes\My Custom Shapes\") and they will automatically be available to be used on tableau under the “my custom shapes” palette




Deixe uma Resposta

Preencha os seus detalhes abaixo ou clique num ícone para iniciar sessão:

Logótipo da

Está a comentar usando a sua conta Terminar Sessão /  Alterar )

Google+ photo

Está a comentar usando a sua conta Google+ Terminar Sessão /  Alterar )

Imagem do Twitter

Está a comentar usando a sua conta Twitter Terminar Sessão /  Alterar )

Facebook photo

Está a comentar usando a sua conta Facebook Terminar Sessão /  Alterar )


Connecting to %s

%d bloggers like this: