Get users in OU with homedir mapped

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

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

Hi Mark,

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

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

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