Get users in OU with homedir mapped

This topic contains 4 replies, has 3 voices, and was last updated by  Mark Prior 3 months, 4 weeks ago.

  • Author
    Posts
  • #69148

    Brian Petersen
    Participant

    Hi,

    I have a OU, with 2500 users. By error, SOME of them have a mapped homedir! but i dont want to go through each user to find WHO has and WHO has not.

    I really need help with Building a script to export all users in the OU, together with thier homedrive. (if mapped or not) og similar solution. Just exported as a list.txt or similar.

    So i can get the users, which has a mapped homedrive on thier profile and reset these with a powershell script, i allready have.
    To save ALOT of time.

    Can someone help me with this fetch script? 😕

    Thx

  • #69154

    Mark Prior
    Participant

    Should get you what your after

    #Select OU
    
    $OU = "OU=Users,OU=Newcastle,OU=United Kingdom,OU=Europe,DC=contoso,DC=microsoft,DC=com"
    
    
    #GetDetails
    Get-ADUser -filter * -SearchBase $ou -Properties homeDirectory, canonicalname, homedirectory | Select-Object name,homedirectory,canonicalname | Out-GridView
    
    
  • #69321

    Brian Petersen
    Participant

    Hi Mark,

    Perfect, it Works perfect 🙂
    But could you output the AD user login name instead of realname?
    Then it would be so cool.

  • #69325

    Hey,
    Just change Select-Object name with Select-Object samaccountname

  • #69330

    Mark Prior
    Participant

    Yep as above just replace or even add after select

    
    #Select OU
    
    $OU = "OU=Users,OU=Newcastle,OU=United Kingdom,OU=Europe,DC=contoso,DC=microsoft,DC=com"
    
    
    #GetDetails
    Get-ADUser -filter * -SearchBase $ou -Properties homeDirectory, canonicalname, homedirectory | Select-Object samaccountname,homedirectory,canonicalname | Out-GridView
    
    

You must be logged in to reply to this topic.