Ernesto Gallardo
asked on
Import emailaddresses, exported from a distribution Group, to another DG
Hi ,
I have a csv file with with the email addresses used by a DG. NOT the email address from the members of the DG , I'm referring to the smtp addresses used by the DG. For Instance: if the DG name is "Graduated students" with email addresses like: gradstudents@domain.com , gradstudents@domain.onmicr osoft.com, gradstudents@mail.domain.c om...
I need a sentence to import those email addresses into another DG in O365.
Thanks,
I have a csv file with with the email addresses used by a DG. NOT the email address from the members of the DG , I'm referring to the smtp addresses used by the DG. For Instance: if the DG name is "Graduated students" with email addresses like: gradstudents@domain.com , gradstudents@domain.onmicr
I need a sentence to import those email addresses into another DG in O365.
Thanks,
ASKER
Thanks Again, I think we are close but , let me explain it more.
Since I'm performing a migration of all the DGs managed by the exchange on premises to O365, I'm running a script that pre-creates the DG in O365 with the prefix "Cloud-" followed by the name of the Group to migrate. but this new pre-created group can't have the email addresses of the old one since they are still assigned to that old group.
So, I'm doing
Import-CSV C:\input.csv | ForEach {Get-DistributionGroup -Identity $_.name | select Displayname, emailaddresses} | Export-Csv C:\emailaddresses1.csv -NoTypeInformation
This will give me a csv file with 2 columms :
Column A= GroupName (e.g: ACE Portfolio)
Column B= Emailaddresses (e.g: smtp:ace_port@mail.barry.e du SMTP:ace_port@barry.edu smtp:ace_port@barryunivers ity.onmicr osoft.com x500:/o=ExchangeLabs/ou=Ex change Administrative Group (FYDIBOHF23SPDLT)/cn=Recip ients/cn=7 bba86b5543 b4192a1d12 a45115c7d9 1-ACE Portfolio X400:C=US;A= ;P=BARRYU;O=BUMAIN;S=ace?p ort; smtp:ace_port@barrynet.bar ry.edu)
After that I delete the groups from the exchange on premises and AD and then After the DGs are also deleted from O365, then I should import the email addresses and remove the cloud- from the name of the group.
When running your sentence adjusted to my names, etc.. this is the error I'm getting
"Cannot process argument transformation on parameter 'EmailAddresses'. Cannot
convert value "System.Collections.Hashta ble" to type
"Microsoft.Exchange.Data.P roxyAddres sCollectio n". Error: "MultiValuedProperty
collections cannot contain null values.
Parameter name: item"
+ CategoryInfo : InvalidData: (:) [Set-DistributionGroup], Parame
terBindin...mationExceptio n
+ FullyQualifiedErrorId : ParameterArgumentTransform ationError ,Set-Distr ib
utionGroup
+ PSComputerName : ps.outlook.com"
Looks like it can't read it in the format i have it...
Since I'm performing a migration of all the DGs managed by the exchange on premises to O365, I'm running a script that pre-creates the DG in O365 with the prefix "Cloud-" followed by the name of the Group to migrate. but this new pre-created group can't have the email addresses of the old one since they are still assigned to that old group.
So, I'm doing
Import-CSV C:\input.csv | ForEach {Get-DistributionGroup -Identity $_.name | select Displayname, emailaddresses} | Export-Csv C:\emailaddresses1.csv -NoTypeInformation
This will give me a csv file with 2 columms :
Column A= GroupName (e.g: ACE Portfolio)
Column B= Emailaddresses (e.g: smtp:ace_port@mail.barry.e
After that I delete the groups from the exchange on premises and AD and then After the DGs are also deleted from O365, then I should import the email addresses and remove the cloud- from the name of the group.
When running your sentence adjusted to my names, etc.. this is the error I'm getting
"Cannot process argument transformation on parameter 'EmailAddresses'. Cannot
convert value "System.Collections.Hashta
"Microsoft.Exchange.Data.P
collections cannot contain null values.
Parameter name: item"
+ CategoryInfo : InvalidData: (:) [Set-DistributionGroup], Parame
terBindin...mationExceptio
+ FullyQualifiedErrorId : ParameterArgumentTransform
utionGroup
+ PSComputerName : ps.outlook.com"
Looks like it can't read it in the format i have it...
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thanks Subsun, but the file exported has empty the column for Email. Only the DisplayName is populated with the Groups.
Just tested, It's working for me.. Does the group shows result for following command
Get-DistributionGroup TestGroup | select Displayname,@{N=“Email”;E={($_.EmailAddresses |? {$_.PrefixString -eq “smtp”} | % {$_.SmtpAddress}) -Join ","}}
If above fails, please post the result for..Get-DistributionGroup TestGroup | select -exp EmailAddresses
ASKER
Hi Subsun,
I had to work on something else. I'll test this tonight and I'll let you know tomorrow. Thanks for all your help . I really appreciate it.
I had to work on something else. I'll test this tonight and I'll let you know tomorrow. Thanks for all your help . I really appreciate it.
ASKER
The first one failed. It doesn't shows anything on the email part. Just empty.
The second one Works this way:
PS C:\Users\XXXXXX> Get-DistributionGroup "ACE Orlando" | select -exp EmailAddresses
SMTP:ace_orlando@barry.edu
smtp:ace_orlando@mail.barr y.edu
smtp:ace_orlando@barryuniv ersity.onm icrosoft.c om
x500:/o=ExchangeLabs/ou=Ex change Administrative Group (FYDIBOHF23SPDLT)/cn=Recip ients/cn=7 6dcb5395be b4525b89e8 3e450035a
82-ACE Orlando
X400:C=US;A= ;P=BARRYU;O=BUMAIN;S=ace?o rlando;
smtp:ace_orlando@barrynet. barry.edu
The second one Works this way:
PS C:\Users\XXXXXX> Get-DistributionGroup "ACE Orlando" | select -exp EmailAddresses
SMTP:ace_orlando@barry.edu
smtp:ace_orlando@mail.barr
smtp:ace_orlando@barryuniv
x500:/o=ExchangeLabs/ou=Ex
82-ACE Orlando
X400:C=US;A= ;P=BARRYU;O=BUMAIN;S=ace?o
smtp:ace_orlando@barrynet.
Is that the exact result you get in powershell console?
Can you test this command and see result?
Can you test this command and see result?
Get-DistributionGroup TestGroup | select Displayname,@{N=“Email”;E={($_.EmailAddresses |? {$_ -match “smtp”} | % {($_ -split ":")[1]}) -Join ","}}
ASKER
DisplayName Email
ACE Orlando ace_orlando@barry.edu,ace_ orlando@ma il.barry.e du,ace_orl ...
This one looks good with emails separated by coma..
Thank you Subsun
ACE Orlando ace_orlando@barry.edu,ace_
This one looks good with emails separated by coma..
Thank you Subsun
Ok you can use the same to export the list..
Import-CSV C:\input.csv | ForEach {Get-DistributionGroup -Identity $_.name | select Displayname,@{N=“Email”;E={($_.EmailAddresses |? {$_ -match “smtp”} | % {($_ -split ":")[1]}) -Join ","}} | Export-Csv C:\emailaddresses1.csv -NoTypeInformation
ASKER
Looks like it should work but is stays like this:
PS C:\Users\gallo> Import-CSV S:\egallardo\test.csv | ForEach {Get-DistributionGroup -Identity $_.name | select Displayname,@{N="Email";E= {($_.Email Addresses |? {$_ -match "smtp"} | % {($_ -split ":")[1]}) -Join ","}} | Export-Csv S:\egallardo\Migration\ema iladdresse s2.csv -NoTypeInformation
>>
>>
And file emailaddresses2.csv is not created.
I even reduce the amount of DGs in test.csv to 19 and still....nothing.it wont come out of that state...
I had to ctrl+C to get out of that state.
PS C:\Users\gallo> Import-CSV S:\egallardo\test.csv | ForEach {Get-DistributionGroup -Identity $_.name | select Displayname,@{N="Email";E=
>>
>>
And file emailaddresses2.csv is not created.
I even reduce the amount of DGs in test.csv to 19 and still....nothing.it wont come out of that state...
I had to ctrl+C to get out of that state.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Yes, That was it , perfect , Now it is created with that format , separated by coma only .
So to later import them into the pre-created ones in O365:
1- Delete from O365 those DGs that I already have pre-created them in O365 and also their email addresses exported.
2.-Remove the Cloud- prefix to that list of pre-created DGs
3.- Now I'm doing : Import-csv S:\Migration\emailaddresse s2.csv | %{Set-DistributionGroup -Identity $_.Displayname -emailaddresses @{Add=($_.Email -Split ",")}} (As you suggested) And Is working Just Fine.
I just need to find a better way now to remove the Cloud- and to reassign the correct email address as the one to use to reply. But I'll try to find it by my self, So far you have Helped me A LOT!!!
Thank you So much Subsun
So to later import them into the pre-created ones in O365:
1- Delete from O365 those DGs that I already have pre-created them in O365 and also their email addresses exported.
2.-Remove the Cloud- prefix to that list of pre-created DGs
3.- Now I'm doing : Import-csv S:\Migration\emailaddresse
I just need to find a better way now to remove the Cloud- and to reassign the correct email address as the one to use to reply. But I'll try to find it by my self, So far you have Helped me A LOT!!!
Thank you So much Subsun
You are welcome!..
ASKER
Susbsun,is the Best, Always replied quickly, and he was helping me all the way until the correct sentence was created. And all that at any time, You guys rock!!!!
Happy to help!
Open in new window
With csv file...Open in new window
Sample CSVOpen in new window
Emails will be updated to group 'Graduated students'In case you if you don't have the export command..
Open in new window