Sheridan Posted February 4, 2013 Posted February 4, 2013 Has anyone got a nice simple script that will let me modify all users (in an AD container) profile path? I need to take their existing profile path, and add a bit and then save it!
etz Posted February 4, 2013 Posted February 4, 2013 I might be being obtuse here, but can't you bulk select the users in AD, then right click properties and put the new profile path in, in the format of \\server-name\share\%username%\additionaldooberrieshere ?
jklight Posted February 4, 2013 Posted February 4, 2013 dsquery user ou=somewhere,dc=over,dc=net | dsmod user -profile users\$username$\profile if it is more complicated then you could send the existing info to a txt file, edit it, and then use it as input to script to make the change. see dsquery | dsmod for an example (uses telephone but you could do profile) Or could use powershell.
Sheridan Posted February 4, 2013 Author Posted February 4, 2013 Problem is the user names have been manually entered (not my system!) so I need to read the existing profile path and then add to it and resave it. The usernames don't always follow a convention either!
Sheridan Posted February 5, 2013 Author Posted February 5, 2013 Well, in the profile path we can have \\server\path\johnsmith or \\server\path\jsmith or even \\server\path\john_smith. These have all been created manually by someone in the past. We need to append a subfolder to each profile path and save it. The %username% variable wasn't used unfortunately
jklight Posted February 5, 2013 Posted February 5, 2013 (edited) And you can't or don't want to fix the inconsistency of username not being a part of the profile path? If not checkout the link in my prior post to use the dsquery command to output to a text file the existing profile path, edit the file, and then use the file as input to a for command loop that runs the dsmod command to save the new profile path in AD. Or maybe do it in powershell. http://techsugar.wordpress.com/2012/04/24/how-to-change-profile-folder-in-active-directory-for-multiple-users-using-powershell/ PS. When using the dsmod command you use $username$ not %username% to represent the username on the account. dsmod user /q to see more Edited February 5, 2013 by jklight
mac_shinobi Posted February 5, 2013 Posted February 5, 2013 Not sure here but would one of the utils from WiseSoft - Resources for IT Professionals ( free registration ) not allow you to do this ? FAQ from wisesoft site : http://www.wisesoft.co.uk/forum/topic131-bulk-updating-profile-paths-using-username.aspx ie : Bulk AD Users - Bulk Modify
Sheridan Posted February 5, 2013 Author Posted February 5, 2013 Hmm, I think dsquery and dsmod might be the quickest way to fettle this. Its a one off and I'm not changing their setup (just helping an associate school thats all) 1
Duke5A Posted February 12, 2013 Posted February 12, 2013 (edited) If you're still plugging away at this, give this a try: Const strHomeDrive = "H" Const strHomePath = "\\server\basehomeshare\" Dim strFailLog Call Main Call WriteLog Sub Main Set oContainer = GetObject("LDAP://OU=Users,DC=domain,DC=com") oContainer.Filter = Array("user") For Each User in oContainer strName = User.samaccountname If CheckPathExist(strName) = True Then User.Put "homedrive", strHomeDrive User.Put "homedirectory", strHomePath & strName User.SetInfo Else strFailLog = strName & " | " & strFailLog End If WScript.Sleep 70 Next Msgbox "Jobs Done!" End Sub Sub WriteLog strFileName = "LogFile.txt" Set objFileSys = CreateObject("Scripting.FileSystemObject") Set objFile = ObjFileSys.CreateTextFile(StrFileName) objFile.Write(strFailLog) objFile.Close End Sub Function CheckPathExist(strName) Set objFileSys = CreateObject("Scripting.FileSystemObject") blnExists = objFileSys.FolderExists(strHomePath & strName) CheckPathExist = blnExists End Function I used this to bulk change the base the home folder path a few years ago when we changed the staff home folder location. It might take some editing to make it work for you. The way it is setup it assumes you have one top level share with folders under that named according to account name. I hope this helps. Edited February 12, 2013 by Duke5A
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now