Solved

Need powershell script to get firstname,lastname,emailaddress,displayname of the users

Posted on 2016-10-05
8
99 Views
Last Modified: 2016-11-01
I have a list with bunch of samaccountnames in it. I need a powershell script which can get me firstname,lastname,displayname,emailaddress of the users based on samaccountname file.

Thanks.
0
Comment
Question by:A D
  • 3
  • 2
8 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 41829995
Try..
Import-Module ActiveDirectory
GC C:\input.txt | % {Get-Aduser $_ -Pr * | Select GivenName,Surname,displayname,emailaddress,samaccountname} | Export-csv C:\report.csv -nti

Open in new window

Input file format..
UserA
UserB
UserC

Open in new window

0
 
LVL 33

Expert Comment

by:it_saige
ID: 41830066
Perhaps something like:
$users = Get-Content C:\_admin\users.txt
$users | ForEach-Object {
    Get-ADUser $_ -Properties * | Select-Object @{l="First Name";e={$_.GivenName}},@{l="Last Name"
;e={$_.Surname}},@{l="Display Name";e={$_.DisplayName}},@{l="E-mail Address";e={$_.Mail}}
}

Open in new window


-saige-
0
 

Author Comment

by:A D
ID: 41831338
Thank you Subsun. It worked perfectly. You're AWESOME!!!
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 40

Expert Comment

by:Subsun
ID: 41831504
You are welcome!
0
 

Author Comment

by:A D
ID: 41856670
This question can be closed. Thanks
0
 
LVL 40

Expert Comment

by:Subsun
ID: 41856890
@A D, Please close the question by accepting the answer! Thanks..
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

This article will help you understand what HashTables are and how to use them in PowerShell.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
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…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

777 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