Over Christmas we plan to change all staff usernames in AD from firstname.lastname to firstinital.lastname - currently we have a system in place that automatically creates a homefolder on the fileserver which is names as the same as the username and shared as username$
If I change all the staff usernames, the connection with their homefolders will all be lost. Does anyone know of a way / script etc that will assist me in not only bulk changing the usernames but also bulk changing the home folder names and also the share names of those homefolders?
Thank you in advance!
OU= Staff > Science
Username = j.bloggs
Homefolder name = j.bloggs
Sharepath = \\fileserver\j.bloggs$
Homefolder physical location = fileserver\d$\Users\Staff\Science\j.bloggs
Please only treat the above as a starting point for your own script - add or change appropriate commands to move folders sintead of creating, set other attributes, etc.Code:Option Explicit Dim objShell Set objShell = CreateObject("Wscript.Shell") Sub listUsers(strOU) Dim oOu, oUser set oOU = GetObject(strOU) For Each oUser in oOU ' Create folders. objShell.Run "cmd /c mkdir \\server\home\" & LCase(oUser.Get("samAccountName")), 1, true ' Set permissions on folders. objShell.Run "cacls \\server\home\" & LCase(oUser.Get("samAccountName")) & " /e /t /p " & LCase(oUser.Get("samAccountName")) & ":f", 1, true ' Set new home folders. oUser.Put "homeDirectory", "\\server\home\" & LCase(oUser.Get("samAccountName")) oUser.Put "homeDrive", "Z:" oUser.SetInfo Next End Sub call listUsers("LDAP://OU=Teachers,OU=SchoolUsers,DC=MyDomain,DC=local") call listUsers("LDAP://OU=Admin,OU=SchoolUsers,DC=MyDomain,DC=local")
There are currently 1 users browsing this thread. (0 members and 1 guests)