Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel user list 1

Status
Not open for further replies.

intel233

MIS
Feb 24, 2007
289
US
Is there a way using powershell that if I have an excel spreadsheet with user names I can get the email address?
 
Can you be more clear about what you want to have when you are done? A list of email addresses? Do you want to use PowerShell to access Exchange, or just to manipulate Excel data? Do you want to dump all the email addresses in the system to an Excel spreadsheet? Or just certain addresses, based on the Excel data?

The answer to all of those is yes, there is a way.

Dave Shackelford
ThirdTier.net
 
Sorry, I was given an excel spreadsheet with 200 usernames. They want the email addresses of all 200 users. These users are spread out over a couple domains and OU's. To go through and manually type this would be very time consuming. I was hoping there was some way with powershell.
 
First create a file called userlist.csv with a single column. The first row should have the word Alias, the rest should be the usernames. Usernames should be the same as their aliases.

Then run this:

Code:
import-Csv userlist.csv | %{Get-Mailbox $_.Alias} | ft displayname,primarysmtpaddress

That will display all the users full names and primary email addresses.

If you want it all exported to another .csv file, you can do this:

Code:
import-Csv userlist.csv | %{Get-Mailbox $_.Alias} | select-object displayname,primarysmtpaddress | export-csv emailaddresses.csv

Dave Shackelford
ThirdTier.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top