Knowledge is of no value, unless you put it into practice

86 Comments

  1. Chris's Gravatar Chris
    November 30, 1999    

    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……..

    • February 23, 2012    

      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.

  2. February 23, 2011    

    Great article! This is exactly what I’m planning to do at my company.

  3. February 25, 2011    

    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

  4. February 27, 2011    
  5. Brian's Gravatar Brian
    March 4, 2011    

    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}

  6. March 5, 2011    

    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

  7. TraciH's Gravatar TraciH
    March 25, 2011    

    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. :)

  8. March 31, 2011    

    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

  9. March 31, 2011    

    Hi Chris. Have you sorted out your problem with group policy blocking the script? Are you running App locker?

  10. Rod's Gravatar Rod
    April 12, 2011    

    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

  11. April 12, 2011    

    Great Rod. Thanks for the updated script.

  12. Josemimos's Gravatar Josemimos
    April 13, 2011    

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

  13. Peter's Gravatar Peter
    April 14, 2011    

    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.

  14. April 20, 2011    

    Hi Peter. Are you sure that the user is getting the policy? Can they read usertile.exe (permissions)

  15. Keith's Gravatar Keith
    May 6, 2011    

    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"

  16. Peter's Gravatar Peter
    May 11, 2011    

    Hi
    Sorry for not getting in touch. How do i see that users are getting the policy?

  17. May 20, 2011    

    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.

  18. Pedro's Gravatar Pedro
    May 21, 2011    

    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.

  19. Pedro's Gravatar Pedro
    May 22, 2011    

    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.

  20. Ali Serhan Cetin's Gravatar Ali Serhan Cetin
    May 30, 2011    

    Awesome Post. Do u have 32 bit version of the Usertile.exe , i couldnt find it?

    • Ahmad reza Mohseni's Gravatar Ahmad reza Mohseni
      March 27, 2012    

      i have this problem.

  21. Pedro's Gravatar Pedro
    June 5, 2011    

    “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

  22. Gustavo's Gravatar Gustavo
    July 7, 2011    

    Congrats. Other congrats to the code that Josemimos was done.

  23. Stéphane's Gravatar Stéphane
    July 19, 2011    

    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.

  24. chauncey's Gravatar chauncey
    October 6, 2011    
  25. JC's Gravatar JC
    November 1, 2011    

    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.

  26. Peter's Gravatar Peter
    November 8, 2011    

    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's Gravatar mitafo
      August 9, 2012    

      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.

  27. November 13, 2011    

    Hi Peter. I am guessing you have software restriction policy or applocker implemented. You need to add usertile.exe as an exception.

  28. Alessandro's Gravatar Alessandro
    November 24, 2011    

    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

  29. RAFFA's Gravatar RAFFA
    December 9, 2011    

    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

  30. December 18, 2011    

    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 :).

  31. February 15, 2012    

    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?

  32. James's Gravatar James
    February 15, 2012    

    Where does the image file save to after uploading?

  33. February 16, 2012    

    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”.

  34. Mike's Gravatar Mike
    March 15, 2012    

    Does you method need any tweaking to work on Windows 8?

    • March 15, 2012    

      Hi. Have not tested this on Windows 8 yet. Should work. :-)

  35. Mike's Gravatar Mike
    March 15, 2012    

    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.

  36. Mike's Gravatar Mike
    March 16, 2012    

    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.

    • March 16, 2012    

      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.

  37. Stephane's Gravatar Stephane
    March 21, 2012    

    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.

  38. Mike's Gravatar Mike
    March 22, 2012    

    @ 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?

  39. Stephane's Gravatar Stephane
    April 16, 2012    

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

  40. April 16, 2012    

    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. :-)

  41. andreas's Gravatar andreas
    April 19, 2012    

    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}

  42. doum's Gravatar doum
    April 24, 2012    

    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)

  43. Ramy's Gravatar Ramy
    May 6, 2012    

    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

  44. Zack's Gravatar Zack
    May 9, 2012    

    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

  45. Alex's Gravatar Alex
    May 15, 2012    

    Great article, but every few days I keep getting the pictures pruned (removed) from Active Directory

  46. dude's Gravatar dude
    May 31, 2012    

    hey, spell check your blog title will ya!

  47. July 17, 2012    

    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

  48. Neil Scott's Gravatar Neil Scott
    August 2, 2012    

    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

  49. denis's Gravatar denis
    September 27, 2012    

    Has anyone try it on Windows 8 or System center 2012?

  50. Jesse Paxson's Gravatar Jesse Paxson
    October 9, 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.

  51. geniom's Gravatar geniom
    November 14, 2012    

    @ 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

  52. saoueel's Gravatar saoueel
    November 15, 2012    

    Hi

    any update to make this work on windows 8 ?

    thank you

  53. November 16, 2012    

    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.

  54. November 30, 2012    

    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

  55. Sunil's Gravatar Sunil
    December 26, 2012    

    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??

  56. Sunil's Gravatar Sunil
    December 27, 2012    

    Please help

  57. Michael's Gravatar Michael
    February 2, 2013    

    Hi. I’d love an elegant solution that works for Win7 and 8. I wish I could code!

  58. Glen Grayban's Gravatar Glen Grayban
    June 6, 2013    

    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

  59. Peter's Gravatar Peter
    August 30, 2013    

    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

  60. Patrick's Gravatar Patrick
    October 2, 2013    

    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.

    • braycraw's Gravatar braycraw
      October 23, 2013    

      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.”
      }
      }
      }
      }
      }

    • April 26, 2014    

      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.

  61. Mahyar's Gravatar Mahyar
    December 24, 2013    

    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.

  62. Rinze de Jong's Gravatar Rinze de Jong
    February 6, 2014    

    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

    • RIaan Strydom's Gravatar RIaan Strydom
      February 28, 2014    

      Hi There,

      Is this a Powershell script? If not, how would I script it as a logon script in Group Policy?

      Thanks!
      Riaan

      • Peter Jahn's Gravatar Peter Jahn
        March 21, 2014    

        It’s vbs.

        But: Where is the useraccountpicture.exe used by the script on windows 7.

    • Peter Jahn's Gravatar Peter Jahn
      March 21, 2014    

      great job. still looking for the useraccountpicture.exe for windows 7

    • i3laze's Gravatar i3laze
      February 13, 2015    

      Damn blog. Had to replace all ” and ‘ in .vbs after copy&paste :)

      Anyone to upload usertile_for_x86.exe?

  63. MiniAdmin's Gravatar MiniAdmin
    February 15, 2014    

    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

  64. March 14, 2014    

    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?

  65. April 26, 2014    

    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.

    • Tim's Gravatar Tim
      May 28, 2014    

      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.

      • Jimmy's Gravatar Jimmy
        July 13, 2014    

        There was a small spelling mistake in first post… Please Re check now.

  66. June 13, 2014    

    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

  67. Nathan Lock's Gravatar Nathan Lock
    June 18, 2014    

    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.

    • rinze de Jong's Gravatar rinze de Jong
      July 13, 2014    

      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

  68. JD's Gravatar JD
    October 29, 2014    

    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.

  69. Bobby.S's Gravatar Bobby.S
    April 9, 2015    

    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. :)

    • Oddvar Håland Moe's Gravatar Oddvar Håland Moe
      April 9, 2015    

      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

  70. Bobby.S's Gravatar Bobby.S
    April 15, 2015    

    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

    • Oddvar Håland Moe's Gravatar Oddvar Håland Moe
      April 16, 2015    

      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 ” ….

No Pings Yet

  1. Setting the user tile image in Windows 7 and Server 2008 R2 « iammarkharrison on January 14, 2012 at 1:11 pm
  2. Pictures in Active Directory Users and Computers | MSitPros Blog on January 17, 2012 at 11:16 pm
  3. Képek a címtárban « DefaultGateway on February 24, 2012 at 12:14 pm
  4. Richard J Green on May 22, 2012 at 12:17 am
  5. Accessing and Editing the Active Directory from C# – WPF » Ricardo Szyfer on June 6, 2012 at 7:24 pm
  6. import picture into Active Directory | Bernhard on wordpress.com on April 29, 2013 at 2:03 pm
  7. User Tile population from AD thumbnailPhoto Windows 8.1 on May 14, 2014 at 3:04 pm
  8. User Tile populace from ADVERTISEMENT thumbnailPhoto Windows 8.1 on June 26, 2014 at 8:43 pm

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Archives