As you all know by now there are several areas you can elevate pictures from Active Directory. What I mean is that you can add a picture to the thumbnailphoto attribute in Active Directory and it will be displayed in Outlook (not only Outlook 2010: http://www.stevieg.org/tag/thumbnailphoto/ ) and Lync. You could also achieve this on SharePoint. But what you probably did not know is that you can also automate the process of setting a user tile picture (User picture) on the start menu on Windows7 clients reading the picture from Active Directory. I will explain the process.
First we need to add a picture to accounts in Active Directory. This can be achieved in many ways. One way is to use the dll from oLID: http://www.dewdney.co.uk/adext/adext.zip (readme inside zip file), another way is to use this tool: http://www.cjwdev.co.uk/Software/ADPhotoEdit/Info.html. A Third option is to use PowerShell. In order to import a picture using powershell you can use this code (you need Active directory modules):

I choose to write the picture to a temporary location and the adding it as a user account pictures using this exe file.
http://www.msitpros.com/wp-content/uploads/usertile.renametoexe
Compiled in X64 – .Net framework 3.5
( This is a compiled version of this code: http://joco.name/2010/12/06/i-discovered-the-new-windows-user-tile-api/ (Thanx Joco!) )
You can compile this code yourself by copying the code from Joco into notepad and save it with a .cs extension. Then you open up cmd and browse to \windows\Microsoft.net\Framework(64 if you want 64 compiled version)v3.5. Here you will find a file called csc.exe.
(Note: I compiled this in 3.5, because this is default installed in Windows 7, if you were to use .Net framework 4 you have to make sure that this is deployed to every workstation since the compiled exe file uses the version you compile it in.)
This is used for compiling code. Inputs are like this: csc.exe c:codeusertile.cs . This will create the usertile.exe inside the path where you execute csc.exe. So there is a crash course in compiling code. J
Okay, back to the automating usertile project. For simplicity in the script I copy the usertile.exe to netlogon folder. Here is the powershell script I use during logon to set the picture on the user account:
$username=$env:username $domain=$env:userdomain $temp=$env:temp $photo = ([ADSISEARCHER]"samaccountname=$($username)").findone().properties.thumbnailphoto $photo | set-content $temp$domain+$username.jpg -Encoding byte $command = "\\labdom\netlogon\usertile.exe $domain$username $temp$domain+$username.jpg" cmd /c $command
As you can see it will connect to my logged on user in Active Directory. Then it will read the thumbnailphoto attribute out to %temp%domain+user.jpg. It will then call the usertile.exe and use this temporary domain+user.jpg file. The next step is to add this as a logon script.
As you all know there is now a great possibility to run PowerShell script at logon with the help of Group Policy.
I created the Usertile.ps1 inside the GPO.
And voila you now have your picture from Active directory on your start menu and logon screen.


Another Cool thing is that if you change the picture in active directory to another picture, this will also change the picture on the computers since the script will always run at logon and will overwrite the existing picture.
And please feel free to comment this post. Remember that this was all tested in a X64 environment. I do not know if this will work in X86 (the usertile.exe). If you have a mix of X86 and X64 you probably need to compile an X86 version of usertile and use that instead.
I must also give credz to xtremedeployment for the reverse engineering of usertile: http://deployment.xtremeconsulting.com/2010/06/23/usertile-automation-part-1/ (Great article)
- http://msexchangeteam.com/archive/2010/03/10/454223.aspx
Pictures in Sharepoint:
- http://www.uccorner.com/188/sharepoint/sharepoint-2010-user-profile-pictures-two-way/
- http://www.arricc.net/active-directory-photos-sharepoint.php
Pictures in Lync:
- http://www.codesalot.com/2010/photos-in-lync-2010/
- http://blogs.technet.com/b/nexthop/archive/2010/11/22/microsoft-lync-2010-photo-experience.aspx
- http://www.msitpros.com/index.php/2009/03/pictures-in-active-directory-users-and-computers/
- http://sysnetadmin.changar.com/2011/02/10/using-outlook-2010-and-thumbnailphoto-in-active-directory/ – Note that it is not necessary to make the attribute replicate to Global catalog (only if you are in a multi domain forest)
62 comments
6 pings
Skip to comment form ↓
Chris
November 30, 1999 at 1:00 am (UTC 2) Link to this comment
Hi, Im getting an error. Have enabled Powerscript witrh RemoteSigned permission but am getting the following:
Unhandled Exception: System.Runtime.InteropServices.COMException (0x800704EC): This program is blocked by group policy……..
James
February 23, 2012 at 5:09 am (UTC 2) Link to this comment
This problem is caused by a Group Policy setting:
Computer -> Control Panel -> User Accounts
Apply the default user logon picture to all users
If this is enabled you will received this error.
Joco
February 23, 2011 at 7:04 pm (UTC 2) Link to this comment
Great article! This is exactly what I’m planning to do at my company.
Ivan
February 25, 2011 at 3:40 am (UTC 2) Link to this comment
Great article! Will have a biger read on the SharePoint/lync stuff soon.
I recommend having a read of http://ivan.dretvic.com/2011/02/gal-photos-in-exchange-2010/ if you want to get HR to do the images for you. There is a program that is standalone and wont require ADUC to do the uploads. To cater for non IT it would need more work to help with searching users and predefining fields, but it would be great for someone to continue the development of it.
The complete VS solution has been uploaded aswell.
Cheers,
ivan
Ivan
February 27, 2011 at 8:25 am (UTC 2) Link to this comment
http://ivan.dretvic.com/2011/02/gal-photos-in-exchange-2010/ link has been changed to http://ivan.dretvich.com/2011/02/gal-photos-in-exchange-2010/. Please update.
Brian
March 4, 2011 at 12:01 am (UTC 2) Link to this comment
Implemented this. Works very well. Thought I’d share my experience. For some users I did not have a photo in AD. In those situations a window would appear alerting that usertile.exe has stopped working. Not a big deal, but a little unsettling to some users. I appended the last line to verify that the $photo variable is not null. Problem solved.
if($photo -ne $null){cmd /c $command}
Oddvar
March 5, 2011 at 5:11 pm (UTC 2) Link to this comment
Great Brian. I thought that I thinked of everything, but probably not…
I like it when you share this experience. This could help other benefit from it. Thanx
TraciH
March 25, 2011 at 3:31 pm (UTC 2) Link to this comment
Thank you. This article is great and very easy to follow. Now I just need to figure out how to syn the pics from Sharepoint mysite over to AD.
Oddvar
March 31, 2011 at 11:30 pm (UTC 2) Link to this comment
Hi Traci. Good to hear that you liked the article. Have you seen this in regards of replicating the picture from sharepoint to Active Directory??
http://blogs.technet.com/b/dcaro/archive/2010/06/05/replicating-user-pictures-from-sharepoint-2010-to-exchange-2010-and-communications-server-14.aspx
Oddvar
March 31, 2011 at 11:32 pm (UTC 2) Link to this comment
Hi Chris. Have you sorted out your problem with group policy blocking the script? Are you running App locker?
Rod
April 12, 2011 at 2:51 am (UTC 2) Link to this comment
I have been looking and finding pieces of this solution for a couple of days. Thanks for pulling it all together and making it easy to follow. I made one improvement to the script, and that is to set a default picture (with our company logo) if there is not yet a user picture stored in AD.
$domain=$env:userdomain
$temp=$env:temp
$photo = ([ADSISEARCHER]“samaccountname=$($username)”).findone().properties.thumbnailphoto
if($photo -eq $null){
$command = “\kaleidahealth.orgnetlogonSetUserTile32.exe $domain$username \kaleidahealth.orgnetlogonDefaultUserAccountPicture.jpg”
} else {
$photo | set-content $temp$domain+$username.jpg -Encoding byte
$command = “\kaleidahealth.orgnetlogonSetUserTile32.exe $domain$username $temp$domain+$username.jpg”
}
cmd /c $command
Oddvar
April 12, 2011 at 1:13 pm (UTC 2) Link to this comment
Great Rod. Thanks for the updated script.
Josemimos
April 13, 2011 at 12:34 pm (UTC 2) Link to this comment
My code, all code into c#:
using System;
using System.IO;
using System.Drawing;
using System.DirectoryServices;
using System.Runtime.InteropServices;
class usertile
{
[DllImport("shell32.dll", EntryPoint = "#262", CharSet = CharSet.Unicode, PreserveSig = false)]
public static extern void SetUserTile(string username, int whatever, string picpath);
[STAThread]
public static void Main()
{
string equipo;
string usuario;
string dominio;
string temporal;
string foto;
byte[] thumb;
MemoryStream ms;
Image imagen;
equipo = Environment.MachineName;
usuario = Environment.UserName;
dominio = Environment.UserDomainName;
temporal = System.IO.Path.GetTempPath();
if (dominio != equipo)
{
DirectoryEntry entry = new DirectoryEntry(“LDAP://” + dominio);
DirectorySearcher Dsearch = new DirectorySearcher(entry);
Dsearch.Filter = “(SAMAccountName=” + usuario + “)”;
Dsearch.PropertiesToLoad.Add(“thumbnailPhoto”);
SearchResult result = Dsearch.FindOne();
if (result.Properties["thumbnailPhoto"].Count > 0)
{
thumb = (byte[])result.Properties["thumbnailPhoto"][0];
ms = new MemoryStream(thumb);
imagen = Image.FromStream(ms);
foto = temporal + dominio + “+” + usuario + “.jpg”;
imagen.Save(foto, System.Drawing.Imaging.ImageFormat.Jpeg);
SetUserTile(dominio + “\” + usuario, 0, foto);
}
}
}
}
Thanks everybody
Peter
April 14, 2011 at 3:12 pm (UTC 2) Link to this comment
Hi
I have followed every step, managed to load photos and can view them in active directory. Created a powershell script and added it to the group policy, but when i log to windows 7 client machine I cannot see any photo. No errors appear. Please help.
Oddvar
April 20, 2011 at 8:52 am (UTC 2) Link to this comment
Hi Peter. Are you sure that the user is getting the policy? Can they read usertile.exe (permissions)
Keith
May 6, 2011 at 4:08 pm (UTC 2) Link to this comment
I was having issues with the error “usertile.exe has stopped working”. My issue was because the usernames have a space in them, so I had to add quotes. I ran into more problems because PowerShell scripts are disabled, and I didn’t want to change that for security purposes. I ended up using a 2-line batch file to do everything. I used the $env:variable format to get everything onto one line. I also used the USERDNSDOMAIN variable to make the script universal, no tweaking needed. It will automatically look for \[FQDN]Netlogonusertile.exe
@ECHO OFF
powershell.exe "([ADSISEARCHER]"samaccountname=$($env:username)").findone().properties.thumbnailphoto | set-content $env:temp$env:userdomain+$env:username.jpg -Encoding byte"
\%UserDNSDomain%netlogonUserTile.exe "%UserDomain%%UserName%" "%TEMP%%UserDomain%+%UserName%.jpg"
Peter
May 11, 2011 at 3:03 pm (UTC 2) Link to this comment
Hi
Sorry for not getting in touch. How do i see that users are getting the policy?
Oddvar
May 20, 2011 at 9:15 am (UTC 2) Link to this comment
Hi Again Peter. I normally use Group Policy Results inside the Group Policy Managment Console to see if the user gets the policy. Remember that the user must be logged on in order for you to run it.
Pedro
May 21, 2011 at 9:26 pm (UTC 2) Link to this comment
Hi everybody! It take some time to find this great solution to get photos from active directory to user computers. I would like to say thanks to all of you who contribute for the solution.
Peter, you can use rsop.msc to check out all policies aplied to computers or users.
Just run the command os the users machine and you get all policies (domain and local) in a graphics interface or you can run gpresult /R on a dos command line and get the same on Windows 7 machines. I believe in XP you just use gpresult without options.
Pedro
May 22, 2011 at 8:17 am (UTC 2) Link to this comment
It seems we have here good solutions.
I would like to leave a quest, since I’m not very good with scripts and I know all of you can help me.
The idea is to use different wallpapers for different OUs.
Our company has many different services and we put the computers on a OU according to the service they belong.
We have created a shared folder with wallpapers for each service.
For now, I’m changing the registry placing in registry the name of the wallpaper to use but I have to make as many scripts as the amount of wallpapers for each service.
Can you help me getting one script that gets the OU of the computer and change the registry key (HKCUControl PanelDesktopWallpaper – Value: \sysvolwallpapersservice1.jpg) to read from the server the correct wallpaper?
Thanks.
Ali Serhan Cetin
May 30, 2011 at 10:19 am (UTC 2) Link to this comment
Awesome Post. Do u have 32 bit version of the Usertile.exe , i couldnt find it?
Ahmad reza Mohseni
March 27, 2012 at 7:37 pm (UTC 2) Link to this comment
i have this problem.
Pedro
June 5, 2011 at 11:49 am (UTC 2) Link to this comment
“different wallpapers for different OUs” – Problem solved.
In fact, using scripts to do most of the job is the solution. I’ve made a script which reads the group user belongs and apply the correct wallpaper. The only problem I have is just the wallpaper only refreshes after user end session and star again. I spend much time looking for a solution to refresh immediately user wallpaper and find something like this:
oShell.Run “%windir%System32RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters”, 1, True
Althought I run this command several times in may script, it doesn’t solved my problem.
Anyone got any idea how to refresh wallpaper after changing registry key?
I leave here my script. As I am not an expert fell free to comment and improve it.
Obviously, all the credits go to people all over the internet who share their knowledge with others.
To Oddvar, special thanks for this Blog which have helped me a lot.
‘Name: logon_script.vbs
‘Description: Logon VBScript and network drive mapping
‘Date: 24-05-2011
‘ Initialize user groups
Const Building1_USERS = “CN= Company _ Building1″
Const Building2_USERS = ” CN= Company _ Building2″
Const Building3_USERS = ” CN= Company _ Building3″
Const Building4_USERS = ” CN= Company _ Building4″
Const Building5_USERS = ” CN= Company _ Building5″
Const Building6_USERS = ” CN= Company _ Building6″
Const Building7_USERS = ” CN= Company _ Building7″
Const Building8_USERS = ” CN= Company _ Building8″
Const Building9_USERS = ” CN= Company _ Building9″
‘ Logon script code
Dim WshNetwork
Dim WshShell
Set WshNetwork = WScript.CreateObject(“WScript.Network”)
Set WshShell = WScript.CreateObject(“WScript.Shell”)
‘ Wallpaper settings
Set oShell = CreateObject(“WScript.Shell”)
Set oFSO = CreateObject(“Scripting.FileSystemObject”)
‘ Define user groups
Set ADSysInfo = CreateObject(“ADSystemInfo”)
Set CurrentUser = GetObject(“LDAP://” & _
ADSysInfo.UserName)
‘User must belong at least to 2 groups
strGroups = Join(CurrentUser.MemberOf)
‘ Removing existing network maps
On Error Resume Next
Set clDrives = WshNetwork.EnumNetworkDrives
For i = 0 to clDrives.Count -1 Step 2
WSHNetwork.RemoveNetworkDrive clDrives.Item(i), True, True
Next
‘ Give time to disconnet drives
WScript.Sleep 1000
‘ Load comun shares
wshNetwork.MapNetworkDrive “N:”, “\nas-serverPublic”
wshNetwork.MapNetworkDrive “P:”, “\namespaceshareshare_name1″, True
wshNetwork.MapNetworkDrive “T:”, “\namespacesharescans” & wshNetwork.UserName
wshNetwork.MapNetworkDrive “U:”, “\namespaceshareUser_Share” & wshNetwork.UserName
share1 = “N: Public ”
share2 = “P: share_name1″
share3 = “T: scans ”
share4 = “U: User_Share ”
‘ Condicional shares
If InStr(strGroups, Building1_USERS) Then
wshNetwork.MapNetworkDrive “Q:”, “\namespaceshareSpecific_share”
share5 = “Q: Specific_share ”
result1 = share1 & ” * ” & share2
result2 = share3 & ” * ” & share4
result3 = share5
result4 = ” ”
‘Register wallpaper registry key
sWinDir = oFSO.GetSpecialFolder(0)
sWallPaper = “\namespaceNETLOGONwallpaperswallpaper-building1.jpg”
‘ update in registry
oShell.RegWrite “HKCUControl PanelDesktopWallpaper”, sWallPaper
‘ let the system know about the change
oShell.Run “%windir%System32RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters”, 1, True
ElseIf InStr(strGroups, Building2_USERS) Then
(…) The same for each building
Else ‘ do not create shares
sWinDir = oFSO.GetSpecialFolder(0)
sWallPaper = “\cmo.localNETLOGONwallpaperswallpaper-other.jpg”
‘ update in registry
oShell.RegWrite “HKCUControl PanelDesktopWallpaper”, sWallPaper
‘ let the system know about the change
oShell.Run “%windir%System32RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters”, 1, True
End If
‘ Do not allow users to change wallpaper
HKEY_CURRENT_USER = &H80000001
strComputer = “.”
Set objReg = GetObject(“winmgmts:\” & strComputer & “rootdefault:StdRegProv”)
strKeyPath = “SoftwareMicrosoftWindowsCurrentVersionPoliciesActiveDesktop”
objReg.CreateKey HKEY_CURRENT_USER, strKeyPath
ValueName = “NoChangingWallpaper”
strValue = “1″
objReg.SetDWORDValue HKEY_CURRENT_USER, strKeyPath, ValueName, strValue
‘ Get current time (only the value of hour)
tempo = abs(Hour(Now()))
‘ Greeting user (Good morning, good afternoon, good night)
If (tempo >= 0 And tempo 12 And tempo <= 19) Then
greet = "Hi, good afternoon! "
Else greet = "Hi, good night! "
End If
Result = WshShell.Popup(greet & VbCrLf _
& VbCrLf & "Your username is: " & WshNetwork.UserName & VbCrLf _
& vbCrLf & "Welcome to the domain: " & WshNetwork.UserDomain & vbCrLf _
& VbCrLf & "Network drives have been mapped!" & VbCrLf _
& VbCrLf & resultado1 & VbCrLf _
& VbCrLf & resultado2 & VbCrLf _
& VbCrLf & resultado3 & VbCrLf _
& VbCrLf & resultado4 & VbCrLf _
& vbCrLf & "NOTE: If you don’t see above shares" & vbCrLf _
& vbCrLf & "please cal IT Departmant" & vbCrLf _
& vbCrLf & "numbers: (Ext. 253, 300, 315, 316)" & vbCrLf _
& vbCrLf & VbCrLf & Space (16)& "Today is: " & (FormatDateTime(Now(),vbLongDate))& VbCrLf _
& vbCrLf & Space (16)& "Time: " & Time & " horas", 10, "CMO Logon Script – Ver.1 Rev.3", 65)
' let the system know about the change
oShell.Run "%windir%System32RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters", 1, True
Gustavo
July 7, 2011 at 5:24 pm (UTC 2) Link to this comment
Congrats. Other congrats to the code that Josemimos was done.
Stéphane
July 19, 2011 at 12:34 pm (UTC 2) Link to this comment
Hi,
First of all, thank you so much for your post, it help me a lot.
I’ve just got a trouble, all my AD pictures resolution are 96×144.
After extract to my Windows 7 ID, the script take the middle of the AD picture to make a 96×96 one.
It mean that my head is cut off on the top. Is there a command line who can take the first 96px (of the 144px) from the top of the AD picture?
Thanks for your help,
Stéphane.
chauncey
October 6, 2011 at 5:00 pm (UTC 2) Link to this comment
This is a great tool for AD photos:
http://www.exclaimer.com/products/outlook-photos/default.aspx
JC
November 1, 2011 at 4:21 pm (UTC 2) Link to this comment
I just found this the other day, and everything worked great. However, after loading one picture for one use, I changed that picture for that same user, and now the old picture still shows.
Did this a day ago, so I would assume any replicating would have taken place now.
Peter
November 8, 2011 at 12:50 pm (UTC 2) Link to this comment
Hi,
I’m having an issue where I get an error:
Unhandled exception: System.Runtime.InteropServices.COMException 90x800704EC): This program is blocked by group policy.
I currently have UAC in place and some other restrictions – I need to know how to allow this program to run correctly?
Thanks
mitafo
August 9, 2012 at 10:04 am (UTC 2) Link to this comment
Hi Peter
This problem is caused by a Group Policy setting:
Go to your local computer group policy settings
Computer Configuration
Administrative Tamplates
Control Panel
User Accounts
Apply the default user logon picture to all users
Choose here disable and restart the computer.
Oddvar
November 13, 2011 at 11:54 pm (UTC 2) Link to this comment
Hi Peter. I am guessing you have software restriction policy or applocker implemented. You need to add usertile.exe as an exception.
Alessandro
November 24, 2011 at 4:16 pm (UTC 2) Link to this comment
sorry for my english im italian user,
this powershell script is only compatible whit windows 2008 server (r2) because i have windows 2003 server r2 and exchange server 2007, client outlook 2010 64bit and windows 7 64bit
thanks
RAFFA
December 9, 2011 at 3:22 pm (UTC 2) Link to this comment
Hi,
i’ve tried your solution on 2 computers in my domain the first win 7 32bit sp1, the second is win 7 64 bit sp1.
On the first pc work perfectly, but on the second the image doesn’t appear, the user image was stored on the temp folder but the usertile.exe don’t seem to work.
thanks for your help
Raffa
Joco
December 18, 2011 at 7:11 pm (UTC 2) Link to this comment
Hey, thanks for the pingback. I may have also sent one but I’m not sure. Anyway, I just published a tool to manage photos in the active directory. It’s free, open source, please give it a try and send feedback:
.
http://joco.name/2011/12/18/adphoto-active-directory-photo-editor-also-introducing-my-tools-project/
I’m also planning to add a command-line interface to it. I don’t have much time so some verbal encouragement would surely help
Dinko
February 15, 2012 at 11:00 am (UTC 2) Link to this comment
Hey, this is great and it works, but we have another problem – we use smartcards for logon, and the picture is displayed when user authenticates with login/password, but not when authenticates with smartcard. Is there a solution to this?
James
February 15, 2012 at 6:34 pm (UTC 2) Link to this comment
Where does the image file save to after uploading?
Oddvar
February 16, 2012 at 7:54 am (UTC 2) Link to this comment
HI Dinko and James. I have not tested with smartcard logons, so I am afraid I do not have the answer.
The image is stored in Active Directory in thumbnailPhoto attribute on the object as a “blob”.
Mike
March 15, 2012 at 3:50 pm (UTC 2) Link to this comment
Does you method need any tweaking to work on Windows 8?
Oddvar
March 15, 2012 at 6:22 pm (UTC 2) Link to this comment
Hi. Have not tested this on Windows 8 yet. Should work.
Mike
March 15, 2012 at 7:19 pm (UTC 2) Link to this comment
Thanks for replying. I’m testing this now on a Windows 8 domain account. It does not work for me. The PowerShell script and the exe run; the .dat file is copied to C:\ProgramData\Microsoft\User Account Pictures, but it is not used. I’m probably missing something.
Mike
March 16, 2012 at 3:26 pm (UTC 2) Link to this comment
Update – I believe your method will not work on Windows 8 Consumer Preview. The architecture of setting and storing account pictures is so different from Windows 7.
By default (first logon by a user), account pictures are read from ProgramData\Microsoft\Default Account Pictures.
When a domain user manually sets an account picture, it is stored in Users\Public\Public Account Pictures\{Sid} as 4 different jpg files (40×40, 96×96, 200×200, and 448×448). If one or more of these is edited manuallly, with Paint for example), that edit will take effect on the first subsequent logon.
Additionally, account picture information is stored in %USERPPROFILE%\Account Pictures in a .accountpicture-ms file. The structure of this file may be similar to the .dat files used with domain user pictures in Windows 7.
As Joco has pointed out in his blog, account picture handling uses a new API (Windows.System.UserProfile namespace). I am very much over my head at this point. Maybe you can make more sense and use of it.
Oddvar
March 16, 2012 at 7:00 pm (UTC 2) Link to this comment
thanks for the info. I think this will be easier to implement in Windows 8. will post an update when I get the time to test it out.
Stephane
March 21, 2012 at 6:41 pm (UTC 2) Link to this comment
Hi,
Many thanks for your totu, it works in my compagny !
I just have a problem at THE FIRST LOGON:
The picture is not downloaded from the AD account, and I get this error : “Usertile.exe stop working, this program has been shutdown…” (it’s not the exact message, just tranlated from french)
Anyway, the pictures il well copied on the computer.
Then the SECOND LOGON
no error message, and it’s working fine.
My question is: Is there a way to put in the program a “continu on error” ? just to not have the error message ?
Thanks by advance for your answers !
Stéphane.
Mike
March 22, 2012 at 4:48 pm (UTC 2) Link to this comment
@ Stéphane – Oddvar will be able to give an authoritative answer, but meanwhile in my experience an error like “usertile.exe stopped working…” suggests that it is not being passed the correct parameters. Have you checked if there is a “\” in the $domain\$username parameter?
Stephane
April 16, 2012 at 5:10 pm (UTC 2) Link to this comment
Thanks for answering, the parameters are correct, because it’s working the second time.
What I can imagine, is that when script is running, the path where the picture is copied, is not fully created… (it’s just a guessing).
Oddvar
April 16, 2012 at 11:29 pm (UTC 2) Link to this comment
Hi Stephane. I did not have this problem in my tests. You could try to add a pause in the script where it reads from AD and runs usertile.exe to update the image.
I will try to recreate this error. Will also try to make a New post on how to do this for Windows 8.
andreas
April 19, 2012 at 10:12 pm (UTC 2) Link to this comment
Thanks for the Usertile. IT WORKS GREATE, but not in windows 8 as pointed out earlier. Looking forward for the windows 8 version.
@Stephane. Try to make some error handling in the powershellscript, so you don’t run the script unless all conditions are meet. We had some simular problems, but that was when the users wasn’t created with a thumbnail, than the usertile crashes. We made a test to se if the powershell actualy returned other than null.
try the following
if(!$photo){exit}
doum
April 24, 2012 at 8:57 am (UTC 2) Link to this comment
Hi,
Thanks, I use your script (modified to use a default company picture if user doesn’t have one) since months.
I put a little comment to not miss a possible adaptation for Windows 8 (I started testing in our domain)
Ramy
May 6, 2012 at 6:46 pm (UTC 2) Link to this comment
i receive the following error
Unhandled Exception: System.Runtime.InteropServices.COMException (0xD0000073): Exception from HRESULT: 0xD0000073
at ConsoleApplication1.Program.SetUserTile(String username, Int32 whatever, String picpath)
at ConsoleApplication1.Program.Main(String[] args)
please, help
Zack
May 9, 2012 at 9:06 pm (UTC 2) Link to this comment
FYI – I have created a simple How-to on Spiceworks going over the basic steps from Photo Import to Logon Script.
http://community.spiceworks.com/how_to/show/2998
Thanks Odvar
Alex
May 15, 2012 at 1:56 am (UTC 2) Link to this comment
Great article, but every few days I keep getting the pictures pruned (removed) from Active Directory
dude
May 31, 2012 at 11:44 pm (UTC 2) Link to this comment
hey, spell check your blog title will ya!
Arricc
July 17, 2012 at 11:44 am (UTC 2) Link to this comment
Yo,
thanks for this
Only comment is that there are some backslashes stripped from the code example…
(hopefully not from this comment though!)
$username=$env:username
$domain=$env:userdomain
$temp=$env:temp
$photo = ([ADSISEARCHER]"samaccountname=$($username)").findone().properties.thumbnailphoto
$photo | set-content $temp\$domain+$username.jpg -Encoding byte
$command = "\\labdom\netlogon\usertile.exe $domain\$username $temp\$domain+$username.jpg"
cmd /c $command
Neil Scott
August 2, 2012 at 3:31 pm (UTC 2) Link to this comment
Running usertile.exe causes an error for me on Win7 x64
“usertile.exe has stopped working”
Description:
Stopped working
Problem signature:
Problem Event Name: CLR20r3
Problem Signature 01: usertile.exe
Problem Signature 02: 0.0.0.0
Problem Signature 03: 4d64f28d
Problem Signature 04: usertile
Problem Signature 05: 0.0.0.0
Problem Signature 06: 4d64f28d
Problem Signature 07: 2
Problem Signature 08: 1
Problem Signature 09: PSZQOADHX1U5ZAHBHOHGHLDGIY4QIXHX
OS Version: 6.1.7600.2.0.0.256.1
Locale ID: 2057
Read our privacy statement online:
http://go.microsoft.com/fwlink/?linkid=104288&clcid=0×0409
If the online privacy statement is not available, please read our privacy statement offline:
C:\Windows\system32\en-US\erofflps.txt
denis
September 27, 2012 at 2:56 pm (UTC 2) Link to this comment
Has anyone try it on Windows 8 or System center 2012?
Jesse Paxson
October 9, 2012 at 6:14 pm (UTC 2) Link to this comment
It does not work in Windows 8. There is a new API out for it, but I haven’t found a way to get it to work without requiring user intervention.
geniom
November 14, 2012 at 5:04 pm (UTC 2) Link to this comment
@ jesse Paxson
What is the new medot you have used?
for win7 x64 are present the news??? in windows 2k8R2 not work, i have error!
What is the permission for the exe?
Thanks
saoueel
November 15, 2012 at 9:08 am (UTC 2) Link to this comment
Hi
any update to make this work on windows 8 ?
thank you
Oddvar
November 16, 2012 at 10:56 am (UTC 2) Link to this comment
I have not written the code, but there is a supported API by Microsoft: http://msdn.microsoft.com/en-us/library/windows/apps/br241881.aspx
So it is possible. Someone just needs to Write the code so it can be used.
Constey
November 30, 2012 at 3:23 pm (UTC 2) Link to this comment
Hey,
i’ve analysed the changing profile picutre a bit, and got to change the profile picture via cmd.
Read here: http://constey.de/?p=752
If you set the profile picture via Windows, it creates a folder with the user sid in here: C:\Users\Public\AccountPictures\ (hidden directory).
In there are pictures with 5 different sizes called “SOMEID-Image40.jpg” “SOMEID-Image96.jpg” and so on. You can place the profile picture via cmdline in that folder by hand, just call the files “Image-40.jpg” “Image-96.jpg” and so on. Just leave the ID away.
It is not that pretty cause the Metro UI seems not reloaded automatically so the profilepicture will be first shown after Locking, or logoff/log in. (just try for yourself)
So now we should need just a way to fetch the picture out of AD and place it in the 5 different sizes in this folder.
(Or wait until someone changes this code:http://joco.name/2010/12/06/i-discovered-the-new-windows-user-tile-api/ for windows 8)
keep working,
constey
Sunil
December 26, 2012 at 1:29 pm (UTC 2) Link to this comment
Hi
I am getting “Usertile.exe has stopped working” message for the users who do not have their pictures in AD.
Do I need to modify anything??
Sunil
December 27, 2012 at 7:33 am (UTC 2) Link to this comment
Please help
Michael
February 2, 2013 at 7:40 pm (UTC 2) Link to this comment
Hi. I’d love an elegant solution that works for Win7 and 8. I wish I could code!
Setting the user tile image in Windows 7 and Server 2008 R2 « iammarkharrison
January 14, 2012 at 1:11 pm (UTC 2) Link to this comment
[...] to follow on that subject. Well, there would have been if someone else had not done it already. It’s really simple to convert the script [...]
Pictures in Active Directory Users and Computers | MSitPros Blog
January 17, 2012 at 11:16 pm (UTC 2) Link to this comment
[...] also wrote a post on using pictures in Active directory: http://msitpros.com/?p=1036 Share [...]
Képek a címtárban « DefaultGateway
February 24, 2012 at 12:14 pm (UTC 2) Link to this comment
[...] a srác komolyan foglakozik a témával: http://msitpros.com/?p=1036 e én egy másik megoldást választottam, egy tisztán PowerShell alapú scrip-et, amit itt [...]
Richard J Green
May 22, 2012 at 12:17 am (UTC 2) Link to this comment
[...] then another community fellow at http://msitpros.com/?p=1036 wrote a PowerShell script to take the work from the first site and script [...]
Accessing and Editing the Active Directory from C# – WPF » Ricardo Szyfer
June 6, 2012 at 7:24 pm (UTC 2) Link to this comment
[...] one with some good links as well from the ITPro’s blog. The fact that we have the same wordpress [...]
import picture into Active Directory | Bernhard on wordpress.com
April 29, 2013 at 2:03 pm (UTC 2) Link to this comment
[...] For more details: http://msitpros.com/?p=1036 [...]