Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Powershell Get-ADuser homedirectory

Posted on 2014-03-18
3
Medium Priority
?
4,942 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 41

Accepted Solution

by:
footech earned 2000 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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

A hard and fast method for reducing Active Directory Administrators members.
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.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
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 …

604 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