Author Posts

April 21, 2017 at 10:36 am

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

April 21, 2017 at 11:20 am

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

April 24, 2017 at 7:34 am

Hi Mark,

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

April 24, 2017 at 8:19 am

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

April 24, 2017 at 10:18 am

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