Jump to content

Recommended Posts

Posted

Hello all,

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!

 

---Example User---

OU= Staff > Science

Username = j.bloggs

Homefolder name = j.bloggs

Sharepath = \\fileserver\j.bloggs$

Homefolder physical location = fileserver\d$\Users\Staff\Science\j.bloggs

--------------------------

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

 

We did something similar - I cludged together the following VBS script to create a folder for each user, set permissions for it and set it as their home folder:

 

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

 

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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...