Link to home
Start Free TrialLog in
Avatar of P S
P S

asked on

Need a powershell script to export email address of users from a list of samaccountnames

I've a CSV file with samaccountnames in it. can someone help with a powershell script to get the email address from the CSV file?.
SOLUTION
Avatar of SubSun
SubSun
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of P S
P S

ASKER

Hey Subsun, Thanks for the response but i am getting error messages while running the script. i've a CSV file with samaccountnames like below.

samaccountname
Test1
Test2
Test3

I just need to retrieve email address of each and every username.

Thanks again!!!
Can you post the Error?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I don't see any issue, the script should work if you are running the code from Exchange Management Shell.
Avatar of P S

ASKER

Sorry but i wasn' t using Exchange shell. It's AD module Powershell.
Ok.. Then Get-Mailbox wont work, you can use Get-ADuser as mentioned in your comment..  :-)
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Question can be closed if @A D doesn't have any further questions..