none
How to change AD-user HomeDirectory for many user? RRS feed

  • Question

  • Hi Guys,

    I think to change all domain user's HomeDirectory

    How to do it?

    like as follow :

    The original location is: microsoft.com\ct
    After replacement: microsoft02.com\ct

    My script :

    ##############################################

    $ctuser = Get-ADUser -Filter * -searchbase "ou=ct,dc=microsoft,dc=com" -Properties SamAccountName,HomeDirectory

    $CT_Type = @()
    Foreach($dci in $ctuser)
    {
            $MemberObject = New-Object System.Object
            $MemberObject | Add-Member -Name SamAccountName -Value $dci.SamAccountName -MemberType NoteProperty
            $MemberObject | Add-Member -Name HomeDirectory -Value $dci.HomeDirectory -MemberType NoteProperty
            $CT_Type += $MemberObject
    }

    foreach($i in $CT_Type)
    {
      Get-ADGroup -Identity $i.SamAccountName |Set-Aduser -HomeDirectory \\microsoft02.com\ct\$_
    }

    ######################################################

    But always show this error message , can you solution for it? Thanks.


    Hi I can't to find solution for solve this issue, I have Event 364 Source File: /Content/1B/DCD02B975BCC454188A2BB1F036E3E590C25641B.exe Destination File: D:\WSUS\WsusContent\1B\DCD02B975BCC454188A2BB1F036E3E590C25641B.exe But I don't know how to deline this KB Number..

    Friday, March 8, 2019 5:39 AM

Answers

All replies

  • Unfortunately your question is not understandable.  Your code also makes no sense.

    Get-ADUser -Filter * -searchbase 'ou=ct,dc=microsoft,dc=com' |
        ForEach-Object{
            $samAccountName = $_.SamAccountName
            $_ | Set-Aduser -HomeDirectory "\\microsoft02.com\ct\$samAccountName"
        }
    


    \_(ツ)_/

    • Marked as answer by jrvModerator Monday, March 11, 2019 1:08 AM
    • Unmarked as answer by Iverson Hsieh Tuesday, March 12, 2019 3:10 AM
    Friday, March 8, 2019 8:25 AM
    Moderator
  • Friday, March 8, 2019 12:34 PM
  • Do you checked this post ? : https://www.morgantechspace.com/2016/04/update-ad-user-home-directory-powershell.html


    Isn't that what I just posted??? ;o)

    \_(ツ)_/

    Friday, March 8, 2019 12:37 PM
    Moderator
  • Hmmm ... maybe ... but your code snippet here does not bring clicks to his site!  ;-)  :-D :-P

    Live long and prosper!

    (79,108,97,102|%{[char]$_})-join''

    Friday, March 8, 2019 12:40 PM
  • Hmmm ... maybe ... but your code snippet here does not bring clicks to his site!  ;-)  :-D :-P

    Live long and prosper!

    (79,108,97,102|%{[char]$_})-join''

    What does that site have to do with my answer?  The site is a bit of confusion but may add exatra.

    I wasn't criticizing your post.  Just wondering why.

    g'day.


    \_(ツ)_/

    Friday, March 8, 2019 1:42 PM
    Moderator
  • you need no script. Use Active Directory -  mark many users - right click properties

    \\server\share\%username%



    Chris

    • Proposed as answer by jrvModerator Friday, March 8, 2019 6:52 PM
    Friday, March 8, 2019 6:19 PM
  • you need no script. Use Active Directory -  mark many users - right click properties

    \\server\share\%username%



    Chris

    It is the easiest way to do a one time thing.  It is also a good way to learn how to do these things before trying to use scripting.  I use the ADUC query editor to build selective queries so I can batch edit object properties.


    \_(ツ)_/

    Friday, March 8, 2019 6:53 PM
    Moderator
  • I think your response is the most meaningless in this forum.

    Hi I can't to find solution for solve this issue, I have Event 364 Source File: /Content/1B/DCD02B975BCC454188A2BB1F036E3E590C25641B.exe Destination File: D:\WSUS\WsusContent\1B\DCD02B975BCC454188A2BB1F036E3E590C25641B.exe But I don't know how to deline this KB Number..

    Monday, March 11, 2019 12:55 AM
  • Do you checked this post ? : https://www.morgantechspace.com/2016/04/update-ad-user-home-directory-powershell.html

    I have completed this script, thank you

    Hi I can't to find solution for solve this issue, I have Event 364 Source File: /Content/1B/DCD02B975BCC454188A2BB1F036E3E590C25641B.exe Destination File: D:\WSUS\WsusContent\1B\DCD02B975BCC454188A2BB1F036E3E590C25641B.exe But I don't know how to deline this KB Number..

    • Marked as answer by Iverson Hsieh Tuesday, March 12, 2019 3:12 AM
    Monday, March 11, 2019 12:56 AM