Solved

Powershell Get-ADuser homedirectory

Posted on 2014-03-18
3
4,595 Views
Last Modified: 2014-03-18
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.
0
Comment
Question by:ITLady45
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 57

Expert Comment

by:Mike Kline
ID: 39938231
Try this

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

Thanks

Mike
0
 
LVL 40

Accepted Solution

by:
footech earned 500 total points
ID: 39938233
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
 

Author Closing Comment

by:ITLady45
ID: 39938643
The suggestion was missing closing bracket.  This was an easy fix for new PS user to figure out.  Thanks for the quick response!
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Uncontrolled local administrators groups within any organization pose a huge security risk. Because these groups are locally managed it becomes difficult to audit and maintain them.
Here's a look at newsworthy articles and community happenings during the last month.
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question