Avatar of P S
P S
 asked on

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

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.
PowershellActive Directory

Avatar of undefined
Last Comment
SubSun

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
SubSun

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
it_saige

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-
P S

ASKER
Thank you Subsun. It worked perfectly. You're AWESOME!!!
SubSun

You are welcome!
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
P S

ASKER
This question can be closed. Thanks
SubSun

@A D, Please close the question by accepting the answer! Thanks..