Changing Home Folder Path for Hundreds of Users

Discussion in 'Active Directory' started by Scott, Jan 25, 2008.

  1. Scott

    Scott Guest

    We are migrating to a new file server and need to change the path to home
    folders for hundreds of user accounts. The path currently points to H:
    \\server1\Users\user.

    If I highlight those hundreds of user accounts in Users & Computers, right
    click properties, profile tab and modify the path as follows:
    H: \\server2\Users\%username% and click 'OK,' will that accomplish my
    objective? Any caveats?

    If there is a preferred method of doing this I'd be interested.
     
    Scott, Jan 25, 2008
    #1
    1. Advertisements

  2. Scott

    Anthony Guest

    That's just fine. Obviously doing it for a few and testing it is good, but I
    assume you planned to do that.
    You can also change it to a DFS path so it never needs to be changed again,
    Anthony, http://www.airdesk.com
     
    Anthony, Jan 25, 2008
    #2
    1. Advertisements

  3. Scott

    Marcin Guest

    Scott,
    assuming that you can easily multi-select all of them, your approach should
    work just fine. Otherwise, you can try the following script, which simply
    enumerates folders under \\server1\Users and modifies the HomeDirectory path
    for all respective user accounts:

    Const ADS_SCOPE_SUBTREE = 2

    sSrvOld = "server1"
    sSrvNew = "server2"
    sShare = "Users"
    sDomainDN = "'LDAP://dc=enter-your-domain-name-here,dc=com"

    Set oConn = CreateObject("ADODB.Connection")
    Set oCommand = CreateObject("ADODB.Command")
    oConn.Provider = "ADsDSOObject"
    oConn.Open "Active Directory Provider"
    Set oCommand.ActiveConnection = oConn

    oCommand.Properties("Page Size") = 1000
    oCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

    Set oFSO = CreateObject("Scripting.FileSystemObject")
    Set oFolder = oFSO.GetFolder("\\" & sSrvOld & "\" & sShare)
    Set cSubFolders = oFolder.Subfolders

    For Each oSubFolder in csubFolders
    oCommand.CommandText = "SELECT Name, HomeDirectory, ADsPath FROM " &
    sDomainDN & _
    " WHERE objectCategory ='user'" & _
    " AND samAccountName='" & oSubFolder.Name & "'"
    Set oRecordSet = oCommand.Execute
    oRecordSet.MoveFirst
    Do Until oRecordSet.EOF
    Set oUser = GetObject(oRecordSet.Fields("ADsPath").Value)
    oUser.HomeDirectory = Replace(oRecordSet.Fields("HomeDirectory").Value,
    sSrvOld, sSrvNew, vbTextCompare)
    oUser.SetInfo
    oRecordSet.MoveNext
    Loop
    Next

    hth
    Marcin
     
    Marcin, Jan 25, 2008
    #3
  4. Jorge de Almeida Pinto [MVP - DS], Jan 26, 2008
    #4
  5. Scott

    Scott Guest

    Marcin,

    Thanks very much. Just two questions:

    1) Is it accurate to say that the only values I would need to customize
    would be the following values: sSrvOld, sSrvNew, sShare and sDomainDN ?

    2) Do I need to execute the .vbs script on a domain controller or can it be
    run from my XP SP2 management workstation?

    Thnx,
     
    Scott, Jan 28, 2008
    #5
  6. Scott

    millin Guest

    Hi Marcin,

    Can I ask a quick question,if your Home folder path is like this..
    \\<sever1>\FirstnameLastname$..How can I replace the sShare=? value?

    thanks
     
    millin, Jan 29, 2008
    #6
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.