«

»

81 comments

8 pings

Skip to comment form

  1. Chris

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

    1. James

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

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

  3. Ivan

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

    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}

  5. Oddvar

    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

  6. TraciH

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

  7. Oddvar

    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

  8. Oddvar

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

  9. Rod

    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

  10. Oddvar

    Great Rod. Thanks for the updated script.

  11. Josemimos

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

  12. Peter

    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.

  13. Oddvar

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

  14. Keith

    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"

  15. Peter

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

  16. Oddvar

    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.

  17. Pedro

    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.

  18. Pedro

    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.

  19. Ali Serhan Cetin

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

    1. Ahmad reza Mohseni

      i have this problem.

  20. Pedro

    “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

  21. Gustavo

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

  22. Stéphane

    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.

  23. chauncey

    This is a great tool for AD photos:
    http://www.exclaimer.com/products/outlook-photos/default.aspx

  24. JC

    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.

  25. Peter

    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

    1. mitafo

      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.

  26. Oddvar

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

  27. Alessandro

    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

  28. RAFFA

    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

  29. Joco

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

  30. Dinko

    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?

  31. James

    Where does the image file save to after uploading?

  32. Oddvar

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

  33. Mike

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

    1. Oddvar

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

  34. Mike

    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.

  35. Mike

    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.

    1. Oddvar

      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.

  36. Stephane

    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.

  37. Mike

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

  38. Stephane

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

  39. Oddvar

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

  40. andreas

    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}

  41. doum

    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)

  42. Ramy

    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

  43. Zack

    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

  44. Alex

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

  45. dude

    hey, spell check your blog title will ya!

  46. Arricc

    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

  47. Neil Scott

    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:\Windows\system32\en-US\erofflps.txt

  48. denis

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

  49. Jesse Paxson

    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.

  50. geniom

    @ 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

  51. saoueel

    Hi

    any update to make this work on windows 8 ?

    thank you

  52. Oddvar

    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.

  53. Constey

    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

  54. Sunil

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

  55. Sunil

    Please help

  56. Michael

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

  57. Glen Grayban

    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

  58. Peter

    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

  59. Patrick

    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.

    1. braycraw

      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(“Local\Temp”,”Roaming\Microsoft\Windows\AccountPictures”)
      $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%\Packages\windows.immersivecontrolpanel_cw5n1h2txyewy\LocalState\Indexed\Settings\en-US\AAA_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.”
      }
      }
      }
      }
      }

    2. Jimmy

      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.

  60. Mahyar

    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.

  61. Rinze de Jong

    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 DOMAIN\username 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 & “\root\cimv2″)
    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 & “\root\cimv2″)

    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 “HKLM\Software\Microsoft\Windows\CurrentVersion\AccountPicture\Users\”& 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 “HKLM\Software\Microsoft\Windows\CurrentVersion\AccountPicture\Users\” & getSid() &”\Image200″, filename, “REG_SZ”
    WshShell.RegWrite “HKLM\Software\Microsoft\Windows\CurrentVersion\AccountPicture\Users\” & getSid() &”\Image240″, filename, “REG_SZ”
    WshShell.RegWrite “HKLM\Software\Microsoft\Windows\CurrentVersion\AccountPicture\Users\” & getSid() &”\Image40″, filename, “REG_SZ”
    WshShell.RegWrite “HKLM\Software\Microsoft\Windows\CurrentVersion\AccountPicture\Users\” & getSid() &”\Image448″, filename, “REG_SZ”
    WshShell.RegWrite “HKLM\Software\Microsoft\Windows\CurrentVersion\AccountPicture\Users\” & 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

    1. RIaan Strydom

      Hi There,

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

      Thanks!
      Riaan

      1. Peter Jahn

        It’s vbs.

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

    2. Peter Jahn

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

  62. MiniAdmin

    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

  63. John

    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?

  64. Jimmy

    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.

    1. Tim

      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.

      1. Jimmy

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

  65. Jourdan Templeton

    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

  66. Nathan Lock

    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:
    MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AccountPicture\User

    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.

    1. rinze de Jong

      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

  67. JD

    I am not using the Netlogon folder but a all access shared drive. Any ideas?

    cmd.exe : ‘\\server01\Public_Applications\UserImages’
    At \\server01\Public_Applications\UserImages\Usertile7.ps1:11 char:4
    + cmd <<<< /c $command
    + CategoryInfo : NotSpecified: ('\\server01\P…ons\UserImages':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.

  1. Setting the user tile image in Windows 7 and Server 2008 R2 « iammarkharrison

    […] 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 […]

  2. Pictures in Active Directory Users and Computers | MSitPros Blog

    […] also wrote a post on using pictures in Active directory: http://msitpros.com/?p=1036 Share […]

  3. Képek a címtárban « DefaultGateway

    […] 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 […]

  4. Richard J Green

    […] then another community fellow at http://msitpros.com/?p=1036 wrote a PowerShell script to take the work from the first site and script […]

  5. Accessing and Editing the Active Directory from C# – WPF » Ricardo Szyfer

    […] one with some good links as well from the ITPro’s blog. The fact that we have the same wordpress […]

  6. User Tile population from AD thumbnailPhoto Windows 8.1

    […] 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 […]

  7. User Tile populace from ADVERTISEMENT thumbnailPhoto Windows 8.1

    […] 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 […]

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>

Current ye@r *

QR Code Business Card