Import contacts to exchange by powershell

Shashika Aravinda
Shashika Aravinda used Ask the Experts™
on
Hi All,

I need to import few contacts from excel sheet to Distribution group as members by powershell. Can someone help me?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
EE Solution Guide - Technical Dept Head
Most Valuable Expert 2017
Commented:
Hi Shashika,
Welcome to Experts Exchange.
Question
Try below cmdlet to import from CSV file...

Import-CSV FileName.csv | ForEach {Add-DistributionGroupMember -Identity "DG Name" -Member $_.Name}

In filename.csv file should have a column header "Name" and should have any of below value to add them as a member.
alias
distinguished name
UPN
LegacyExchangeDN
Domain\Account Name
SMTP Address

Thanks
MAS

Author

Commented:
Hi,Thanks for reply,

PS error showing add-distributiongroupmember is invalid
MASEE Solution Guide - Technical Dept Head
Most Valuable Expert 2017

Commented:
Please post screenshot
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
This error is showing nowCapture.PNG
MASEE Solution Guide - Technical Dept Head
Most Valuable Expert 2017

Commented:
Apologize for the delayed response.
What is the version of Exchange?
Please show me the CSV format (screenshot)
SysToolsData Expert - Recovery,Backup,Migration

Commented:
Note: First Covert Excel Sheet Contacts to CSV format first

I think you are not providing the correct  Parameter :

Import-CSV FileName.csv | ForEach {Add-DistributionGroupMember -Identity "DG Name" -Member $_.Name}

For Ex:

Add-DistributionGroupMember -Identity "Staff" -Member "JohnEvans@contoso.com"

Member $_.Name:
JohnEvans@contoso.com

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial