Powershell Get-ADuser homedirectory

I am new to powershell.  
I need a powershell script that exports the homedirectory of various AD users in different OUS.  I already have a list of users.  Is it possibly to call a txt  file that has the users' AD samaccountname and then outputs the findings to a csv file that displays their Fullname and homedirectory.
ITLady45Asked:
Who is Participating?
 
footechConnect With a Mentor Commented:
If you have at least one 2008 R2 DC, then you can use MS' AD cmdlets without anything further.  Since "Fullname" is not an AD attribute, you have to choose which you want to use (possibly "Name", "DisplayName", etc.).
Import-Module ActiveDirectory
Get-Content users.txt | ForEach {Get-ADUser $_ -properties DisplayName,HomeDirectory | Select DisplayName,HomeDirectory | Export-CSV userinfo.csv -notype

Open in new window

0
 
Mike KlineCommented:
Try this

get-content c:\users.txt | get-aduser -properties * | select-object name, sn, givenname , homedirectory

Thanks

Mike
0
 
ITLady45Author Commented:
The suggestion was missing closing bracket.  This was an easy fix for new PS user to figure out.  Thanks for the quick response!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.