Link to home
Create AccountLog in
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.
ASKER CERTIFIED SOLUTION
Avatar of SubSun
SubSun
Flag of India image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
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-
Avatar of P S
P S

ASKER

Thank you Subsun. It worked perfectly. You're AWESOME!!!
You are welcome!
Avatar of P S

ASKER

This question can be closed. Thanks
@A D, Please close the question by accepting the answer! Thanks..