Compound command

Hello all,

I know that it is very possible to combine the two commands of:

Import-Csv c:\Users\USERID\contacts.csv | ForEach {New-MailContact -Name $_.Name -Firstname $_.FirstName -LastName $_.LastName -ExternalEmailAddress $_.ExternalEmailAddress -Alias $_.Alias -OrganizationalUnit DOMAIN.COM/Folder1/Folder2}
Import-csv C:\Users\USERID\contacts.csv | foreach {add-distributiongroupmember -id NAME_OF_DISTROLIST -member $_.ExternalEmailAddress

How can I do it?
April 6th, 2015 8:28am

Import-Csv c:\Users\USERID\contacts.csv | ForEach { New-MailContact -Name $_.Name -Firstname $_.FirstName -LastName $_.LastName -ExternalEmailAddress $_.ExternalEmailAddress -Alias $_.Alias -OrganizationalUnit DOMAIN.COM/Folder1/Folder2; add-distributiongroupmember -id NAME_OF_DISTROLIST -member $_.ExternalEmailAddress }

Should work, assuming you have all the relevant columns in the CSV.

Free Windows Admin Tool Kit Click here and download it now
April 6th, 2015 4:27pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics