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 recommend using one of the gui methods, because they shrink the size of the image before they are written to the thumbnailphoto attribute. I like the adext.zip extension best. Here are screenshots when I add a picture to a user after I have installed the adext.zip:
I choose to write the picture to a temporary location and the adding it as a user account pictures using this exe file.
http://msitpros.com/wp-content/uploads/usertile.exe
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 windowsMicrosoft.netFramework(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:
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)
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://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)
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……..
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.
I have a solution that works great for both Windows 8 and Windows 10.
It uses PowerShell to fetch the Active Directory data and then sets it as the local profiles picture.
Read more at: https://heineborn.com/tech/ad-user-pictures-in-windows-10
Great article! This is exactly what I’m planning to do at my company.
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
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.
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}
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
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. 🙂
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
Hi Chris. Have you sorted out your problem with group policy blocking the script? Are you running App locker?
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.
$username=$env:username
$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
Great Rod. Thanks for the updated script.
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 🙂
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.
Hi Peter. Are you sure that the user is getting the policy? Can they read usertile.exe (permissions)
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"
Hi
Sorry for not getting in touch. How do i see that users are getting the policy?
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.
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.
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.
Awesome Post. Do u have 32 bit version of the Usertile.exe , i couldnt find it?
i have this problem.
“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
Congrats. Other congrats to the code that Josemimos was done.
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.
This is a great tool for AD photos:
http://www.exclaimer.com/products/outlook-photos/default.aspx
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.
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
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.
Hi Peter. I am guessing you have software restriction policy or applocker implemented. You need to add usertile.exe as an exception.
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
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
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 :).
[…] 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 […]
[…] also wrote a post on using pictures in Active directory: http://msitpros.com/?p=1036 Share […]
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?
Where does the image file save to after uploading?
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”.
[…] 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 […]
Does you method need any tweaking to work on Windows 8?
Hi. Have not tested this on Windows 8 yet. Should work. 🙂
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:ProgramDataMicrosoftUser Account Pictures, but it is not used. I’m probably missing something.
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 ProgramDataMicrosoftDefault Account Pictures.
When a domain user manually sets an account picture, it is stored in UsersPublicPublic 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.
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.
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.
@ 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?
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).
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. 🙂
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}
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)
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
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
Great article, but every few days I keep getting the pictures pruned (removed) from Active Directory
[…] then another community fellow at http://msitpros.com/?p=1036 wrote a PowerShell script to take the work from the first site and script […]
hey, spell check your blog title will ya!
[…] one with some good links as well from the ITPro’s blog. The fact that we have the same wordpress […]
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 = "\labdomnetlogonusertile.exe $domain$username $temp$domain+$username.jpg"
cmd /c $command
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=0x0409
If the online privacy statement is not available, please read our privacy statement offline:
C:Windowssystem32en-USerofflps.txt
Has anyone try it on Windows 8 or System center 2012?
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.
@ 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
Hi
any update to make this work on windows 8 ?
thank you
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.
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:UsersPublicAccountPictures (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
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??
Please help
Hi. I’d love an elegant solution that works for Win7 and 8. I wish I could code!
[…] For more details: http://msitpros.com/?p=1036 […]
Picture resizing can also be done in ASP or VBScript. We have a directory HR puts the photos in. When they open the employees HR information, our code copies the file to a temp area on the web server and resizes the picture for badges and for Intranet usage and copies the file back to the original directory. Then the page resizes the picture again and then imports it into active directory. I don’t have a lot of time to go through the long process and code, but below is some of the resizing code:
Set objIFWeb = CreateObject(“WIA.ImageFile”)
Set objIFLync = CreateObject(“WIA.ImageFile”)
Set objIPWeb = CreateObject(“WIA.ImageProcess”)
Set objIPLync = CreateObject(“WIA.ImageProcess”)
Set objFSO = CreateObject(“scripting.filesystemobject”)
objIFWeb.LoadFile MyFile
objIPWeb.Filters.Add objIPWeb.FilterInfos(“Scale”).FilterID
objIPWeb.Filters(1).Properties(“MaximumWidth”) = 250
objIPWeb.Filters(1).Properties(“MaximumHeight”) = 250
Set objIFWeb = objIPWeb.Apply(objIFWeb)
objIFWeb.SaveFile(MyFileTemp)
objFSO.deletefile(MyFile)
objFSO.copyfile MyFileTemp, MyFile
objIFLync.LoadFile MyFile
objIPLync.Filters.Add objIPLync.FilterInfos(“Scale”).FilterID
objIPLync.Filters(1).Properties(“MaximumWidth”) = 96
objIPLync.Filters(1).Properties(“MaximumHeight”) = 96
Set objIFLync = objIPLync.Apply(objIFLync)
If objFSO.FileExists(MyFileTemp) Then
objFSO.deletefile(MyFileTemp)
End If
This looks awesome, however when I try to implement the gpo with the powershell login script – the powershell option is not displayed in the logon properties screen (as it is above)
So instead of showing ‘scripts’ and ‘powershell scripts’, it only shows ‘scripts’. I’m running SBS 2008.
Any ideas?
Thanks
Anyone with a little more programming experience think they can use the following to get this working with Windows 8.1, etc? http://code.msdn.microsoft.com/windowsapps/Account-picture-name-sample-912baff1 My head might explode if I attempt this.
Here is a sample PowerShell script I use to change everyone who has a default account picture to the Active Directory picture in Windows 8.1.
It saves the jpg to My Pictures folder and opens the account settings area in windows 8. It works as a limited user also.
Parts of this code were plagiarized from other sources.
Note: It requires user intervention only the first time it executes – maybe somebody more code-savvy could modify this so you don’t have to.
$username=$env:username
$domain=$env:userdomain
$temp=$env:temp
$changed=$false
$accountpictures=$temp.Replace(“LocalTemp”,”RoamingMicrosoftWindowsAccountPictures”)
$pictures=[Environment]::GetFolderPath(“MyPictures”)
$path=”$pictures$domain+$username.jpg”
$photo = ([ADSISEARCHER]”samaccountname=$($username)”).findone().properties.thumbnailphoto
if($photo -eq $null)
{
exit
}
else
{
$photo | set-content $path -Encoding byte
[Windows.System.UserProfile.UserInformation,Windows.System.UserProfile,ContentType=WindowsRuntime] > $null
if([Windows.System.UserProfile.UserInformation]::AccountPictureChangeEnabled -eq $true)
{
if([Windows.System.UserProfile.UserInformation]::GetAccountPicture(1).Name -eq “user.png”)
{
Write-Host “Please browse to User Account Picture in Pictures folder”
$command = “del /q “””+$accountpictures+”*.*”””
cmd /c $command
$command = “%windir%explorer.exe %localappdata%Packageswindows.immersivecontrolpanel_cw5n1h2txyewyLocalStateIndexedSettingsen-USAAA_SettingsGroupYourAccount.settingcontent-ms”
cmd /c $command
while($changed -eq $false)
{
[System.Threading.Thread]::Sleep(1000)
if([Windows.System.UserProfile.UserInformation]::GetAccountPicture(1).Name -ne “user.png”)
{
$changed=$true
Write-Host “Thank you.”
}
}
}
}
}
Visit http://www.parackattu.com/2014/04/windows-8-windows-81-set-account.html
Here you can find, how to set user tile (Account Picture) from active directory on a Windows 8 & Windows 8.1 domain member.
Nice article. But I have a question Chris. In the very first screenshot I see you have additional tabs in User Properties like Photo and Employee. I wonder how you managed to do that? I have been searching a lot to add a custom tab in active directory user properties but there was no result. Would you please share us how you did that?
Regards.
Here is a script which will replace the current profile picture in Windows 7 and 8 with the picture saved in AD
‘Function which will load the picture from AD on DOMAINusername for the logged on user
Function LoadPictureFromAD(szADsPath, szSaveFileName)
Dim objUser, bytesRead, adoStreamWrite
Const adTypeBinary = 1, adSaveCreateOverWrite = 2
Set objUser = GetObject(szADsPath)
bytesRead = objUser.Get(“thumbnailPhoto”)
Set adoStreamWrite = CreateObject(“ADODB.Stream”)
adoStreamWrite.Type = adTypeBinary
adoStreamWrite.Open
adoStreamWrite.Write(bytesRead)
adoStreamWrite.SaveToFile szSaveFileName, adSaveCreateOverWrite
adoStreamWrite.Close
End Function
‘Function which will check the running OS Version
Function getOSVersion()
strComputer = “.”
Set objWMIService = GetObject(“winmgmts:” & “{impersonationLevel=impersonate}!\” & strComputer & “rootcimv2”)
Set colOperatingSystems = objWMIService.ExecQuery(“Select * from Win32_OperatingSystem”)
For Each objOperatingSystem in colOperatingSystems
getOSVersion = objOperatingSystem.Version
Next
End Function
‘Function which will get the SID of the logged on user from AD
Private Function getSid()
strComputer = “.”
Set objWMIService = GetObject(“winmgmts:\” & strComputer & “rootcimv2”)
Set objAccount = objWMIService.Get(“Win32_UserAccount.Name='” & strUsername & “‘,Domain='” & strDomain & “‘”)
getSID = objAccount.SID
End Function
‘Set the variables for the script
Set wshShell = CreateObject(“WScript.Shell”)
Set wshNetwork = WScript.CreateObject(“WScript.Network”)
Set objSysInfo = CreateObject(“ADSystemInfo”)
set oFSO = CreateObject(“Scripting.FileSystemObject”)
workingdir = Replace(wscript.scriptfullname, Wscript.scriptname, “”)
username = wshNetwork.UserDomain & “” & wshNetwork.UserName
strUserName = objSysInfo.UserName
dn = “LDAP://” & strUserName
path = wshShell.ExpandEnvironmentStrings(“%temp%”) & “”
filename = path & “uap.jpg”
‘Store AD Picture in %temp%uap.jpg
LoadPictureFromAD dn, filename
‘Run the useraccountpicture.exe for changing the User Account Picture on Windows 7 systems (W7 & W7sp1)
if ((getOSVersion() = “6.1.7600”) Or (getOSVersion() = “6.1.7601”)) Then
wshshell.run workingdir & “useraccountpicture.exe ” & username & ” ” & filename, 0, true
Else
‘Call UAC rights if not having admin rights
Call ElevateUAC
‘find current user & domain
strUsername = wshShell.ExpandEnvironmentStrings(“%USERNAME%”)
strDomain = wshShell.ExpandEnvironmentStrings(“%USERDOMAIN%”)
Wscript.sleep 1000
strFileName = oFSO.GetTempName
set oFile = oFSO.CreateTextFile(strFileName)
‘Change right on Registry key for changing the path which will look for the uap.jpg
oFile.WriteLine “HKLMSoftwareMicrosoftWindowsCurrentVersionAccountPictureUsers”& getSid() &” [1 7 17]”
oFile.Close
WshShell.Run “regini ” & strFileName, 8, true
‘Write the registry changes to the Register (GetSID is current User SID, filename is %temp%uap.jpg)
WshShell.RegWrite “HKLMSoftwareMicrosoftWindowsCurrentVersionAccountPictureUsers” & getSid() &”Image200″, filename, “REG_SZ”
WshShell.RegWrite “HKLMSoftwareMicrosoftWindowsCurrentVersionAccountPictureUsers” & getSid() &”Image240″, filename, “REG_SZ”
WshShell.RegWrite “HKLMSoftwareMicrosoftWindowsCurrentVersionAccountPictureUsers” & getSid() &”Image40″, filename, “REG_SZ”
WshShell.RegWrite “HKLMSoftwareMicrosoftWindowsCurrentVersionAccountPictureUsers” & getSid() &”Image448″, filename, “REG_SZ”
WshShell.RegWrite “HKLMSoftwareMicrosoftWindowsCurrentVersionAccountPictureUsers” & getSid() &”Image96″, filename, “REG_SZ”
oFSO.DeleteFile strFileName
Sub ElevateUAC
If Not WScript.Arguments.Named.Exists(“elevated”) Then
‘Launch the script again as administrator
With CreateObject(“Shell.Application”)
.ShellExecute “wscript.exe”, “””” & _
WScript.ScriptFullName & “”” /elevated”, “”, “runas”, 1
WScript.Quit
End With
End If
End Sub
End If
Hi There,
Is this a Powershell script? If not, how would I script it as a logon script in Group Policy?
Thanks!
Riaan
It’s vbs.
But: Where is the useraccountpicture.exe used by the script on windows 7.
great job. still looking for the useraccountpicture.exe for windows 7
Damn blog. Had to replace all ” and ‘ in .vbs after copy&paste 🙂
Anyone to upload usertile_for_x86.exe?
Hi All.
Thank you for sharing allthis usefull stuff.
I am still looking for a Windows 2012 (RDS) or Windows 8 solution for changing account picture programmatically.
Anyway, i wanted to let you know, that there is a very nice free tool for uploading images in AD with a nice GUI solution.
It’s called CodeTwo Active Directory Photos, download here: http://www.codetwo.de/freeware/active-directory-photos/
cheers
I am trying to figure out how you are getting the photo to appear in ADUC? I was able to get the pictures uploaded into AD using one of the GUI tools, I installed OSC for Outlook 2007 and my photos appear but I can’t get the photo tile to appear in ADUC. I tried using userproppage.dll which I thought allowed it but no dice. Any write up on that?
Visit http://www.parackattu.com/2014/04/windows-8-windows-81-set-account.html
Here you can find, how to set user tile (Account Picture) from active directory on a Windows 8 & Windows 8.1 domain member.
Were you actually able to get that UserTile8 program to work? I have had no success in doing so and looks like those who’ve comment on that site havent either.
There was a small spelling mistake in first post… Please Re check now.
[…] for the 8.1 tile that is missing. Having tried many blogs and other links, nothing seems to work. Using Pictures from Active Directory | MSitPros BlogWindows 8 Account picture name sample in C#, VB.NET, C++, JavaScript for Visual Studio 2013 […]
Hi there, thanks heaps for your blog post. Helped me to write a PowerShell version of UserTile8. Works great! Check it out here if you are interested: http://blog.jourdant.me/ps-setting-windows-8-account-picture-from-ad
I have got this all working on windows 8.1 by using both usertile from codeplex and the usertile8, here are my full instructions.
————–
most of these instructions are taken from http://www.parackattu.com/2014/04/windows-8-windows-81-set-account.html
Step 1. Create a GPO in your server & ensure it is applicable only to Windows 8 & Windows 8.1 clients by using a WMI filter
You can create a WMI filter using below Query, give a proper Name (In my case: Win8 & 8.1 OS Computers)
SELECT * FROM Win32_OperatingSystem WHERE (Version LIKE “6.2%” or Version LIKE “6.3%” ) AND ProductType = 1
Step 2. Download and save “UserTile8.exe” to a shared folder that everyone can access.
https://drive.google.com/file/d/0B02U96oxeg2pYzQ2eUVKdjRaRTg/edit?usp=sharing
Step 3 Edit the group policy ClientOS Settings-Win8 & 8.1
Go to Computer Configuration->policies-> Windows Settings -> Security Settings – Registry
Right Click on Registry and select Add Key
Add the below Key:
MACHINESOFTWAREMicrosoftWindowsCurrentVersionAccountPictureUser
Give Full Permission on this key (and sub keys) to Users
Ensure security is applies to this Keys and sub keys from advanced security
Also make sure you have selected “Replace Existing permission on all sub keys with inheritable permissions.”
Step 4 Now we have to enable an option to execute UserTile8.exe on user login. Here I am going to make a scheduled task in group policy for that. (Even you can make your own procedure like logon script to do it)
To make a scheduled task in GPO:
Edit the group policy ClientOS Settings-Win8 & 8.1
User Configuration-> Preferences->Control Panel Settings -> Scheduled Tasks
Right Click and select New Sheduled Task (At lest Windows 7) Option
From General Tab
Set Name as: SetUserTile
Select Hidden ( to ensure UserTile8 is hidden on background when a user login to the computer)
From Triggers Tab
Create a new trigger and select Begin the task: At Login, Any User
From Actions Tab
Create New Action Select Action “start Program”
From Program Script Option
Select the UserTile8.exe from the shared folder.
Press Ok buttons and save it.
Step 5 download also download usertile from http://adusertile.codeplex.com/ (usertile.exe)
This one seems to set the profile picture used at logon.
Step 6 repeat step 4 to also run usertile.exe that you downloaded in step 5.
——
Note: usertile.exe requires .net framework 3.5 to be installed on your windows 8 machine.
—-
other alternatives that use powershell can be found at :-
http://blog.jourdant.me/ps-setting-windows-8-account-picture-from-ad/
and the vbscript from http://msitpros.com/?p=1036 but it kept prompting for UAC permission to run.
In reply to my earlier post, it is written in VBS. You have to make a new AD policy and place the vbscript as logon script. Place the vbs with the useraccountpicture.exe (in the script renamed to uap.jpg) in the same rootfolder of the policy. The exe you can download from the link provided in the main post: link is this http://www.msitpros.com/wp-content/uploads/usertile.renametoexe. The exe is compiled in x64. If you want to run this on 32bits recompile it with c# with the source code provided in the main post link is underneath above link.
This script wil run on computers with Windows 7, Windows 8 32 and 64 bits
[…] Having actually attempted numerous blog sites and other links, absolutely nothing appears to work. Using Pictures from Active Directory | MSitPros Blog. SetAccountPicture.xaml.h – Account picture name sample. PowerShell script to get AD-Pictures works […]
I am not using the Netlogon folder but a all access shared drive. Any ideas?
cmd.exe : ‘\server01Public_ApplicationsUserImages’
At \server01Public_ApplicationsUserImagesUsertile7.ps1:11 char:4
+ cmd <<<< /c $command
+ CategoryInfo : NotSpecified: ('\server01P…onsUserImages':String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
Hi Oddvar,
can you pls upload the “http://msitpros.com/wp-content/uploads/usertile.renametoexe
Compiled in X64 – .Net framework 3.5” again ?
I cant see behind this link anything..
Thanks. 🙂
Hi. Something strange on the server since it is not allowing .renametoexe extension. I just uploaded the file again as usertile.exe and updated the blogpost. Thank you for pointing this out to us.
http://msitpros.com/wp-content/uploads/usertile.exe
Hi Oddvar,
i have tried to use the “usertile.exe” to import the thumbnail pic into the userpicture, but everytime i try, the “usertile.exe” get stopped and it dont work.
The first part of the script works, he gets the picture and put it in the directory i want..
But than the usertile just stops and windows gave me this:
“Beschreibung:
Stopped working
Problemsignatur:
Problemereignisname: CLR20r3
Problemsignatur 01: usertile.exe
Problemsignatur 02: 0.0.0.0
Problemsignatur 03: 4d64f28d
Problemsignatur 04: usertile
Problemsignatur 05: 0.0.0.0
Problemsignatur 06: 4d64f28d
Problemsignatur 07: 2
Problemsignatur 08: 1
Problemsignatur 09: System.IO.FileNotFoundException
Betriebsystemversion: 6.1.7601.2.1.0.256.48
Gebietsschema-ID: 1031
“
Hi Bobby.
Sometimes when you copy code from blogposts the ” signs gets screwed up. Open Your PowerShell script to see if it is the correct. “ vs ” ….
Hi guys!
I have another question to the synchronization. I want that when my domain members change their profile picture to another one it should be synchronized with active directory. How can I implement that?
best regards
Chris
I would like to add the photo tab to my active directory on Windows Server 2012 and to be 2016 however the tool to download on http://www.dewdney.co.uk/adext/adext.zip is not working anymore the website seems to be empty and the file seems to be removed. Do you or someone have this zip file somewhere and is willing to share this so it can be added to my server / management server and RSAT if available for windows 10.
Thankx in advance
We do use Lepide Active Directory Bulk Image Editor tool (http://www.lepide.com/freetools/ad-bulk-image-editor.html ) while need to upload and manage images in Active Directory’s thumbnailPhoto and jpegPhoto attributes. It’s a very effective replacement of command line tool that you use otherwise to upload images. Using this tool you can upload, remove, change and export images in bulk.
[…] 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 […]
I’ll immediately snatch your rss as I can not to find your email
subscription hyperlink or e-newsletter service. Do
you have any? Please let me recognize so that I could subscribe.
Thanks.
Hi. Our RSS feed is: http://msitpros.com/?feed=rss2
[…] https://msitpros.com/?p=1036 […]
Lync 2013 Drifttips
Legge til eksterne kontakter Lync er åpnet opp f
Great. Thanks for script.
Verry good post. I am going thnrough some of these issues as well..