orbisuser
asked on
Office 365 group suffix email change?
Hi, I am trying to change all my group email suffixes in Office 365? For example, it's currently <some department@domain.org> and I'd like to change it where it displays in Outlook as <some department@domain2.org>. However I don't want to make this change for one department alone but for all departments past, present, and future moving forward.
I need to take these 2 scripts and make them iteratively for all my Office 365 groups moving forward.
PS C:\Users\david.shibuya> Set-UnifiedGroup -Identify Legal_team -Email Addresses @{add="legal_team@orbis.or g"}
PS C:\Users\david.shibuya> Set-UnifiedGroup -Identify Legal_team -PrimarySmtpAddress legal_team@orbis.org
I need to take these 2 scripts and make them iteratively for all my Office 365 groups moving forward.
PS C:\Users\david.shibuya> Set-UnifiedGroup -Identify Legal_team -Email Addresses @{add="legal_team@orbis.or
PS C:\Users\david.shibuya> Set-UnifiedGroup -Identify Legal_team -PrimarySmtpAddress legal_team@orbis.org
Use an email address policy: https://docs.microsoft.com/en-us/office365/admin/create-groups/choose-domain-to-create-groups?view=o365-worldwide
ASKER
Hi Vasil,
What I actually need is a script that for each EXISTING Office 365 Group in Exchange Online, adds a SMTP mail address that uses the internal relay domain (@orbis.org), then sets that address as the primary SMTP address for the group. Is this possible and if so, how?
What I actually need is a script that for each EXISTING Office 365 Group in Exchange Online, adds a SMTP mail address that uses the internal relay domain (@orbis.org), then sets that address as the primary SMTP address for the group. Is this possible and if so, how?
Well you did say "moving forward". The cmdlets you have outlined above would do just fine for existing groups. Apart from that all you need is a simple filter to find the ones that currently have "incorrect" address.
ASKER
I'm looking for something like this:
$Groups = Get-UnifiedGroup where-object {$_.PrimarySMTPAddress -like "*@<old_domain>"
for Each $Group in $Groups
Set-unified group -EmailAddresses @{add="<alias>@<newdomain> "};
Set-unifiedGroup -PrimarySMTPAddress "<alias>@<new_domain>"
Is there a PowerShell expert that could review the syntax in this code? Specifically, how do you write a where-object cmdlet so that it matches PART of a string pattern, in this case, the old domain suffix for the Group email address.
$Groups = Get-UnifiedGroup where-object {$_.PrimarySMTPAddress -like "*@<old_domain>"
for Each $Group in $Groups
Set-unified group -EmailAddresses @{add="<alias>@<newdomain>
Set-unifiedGroup -PrimarySMTPAddress "<alias>@<new_domain>"
Is there a PowerShell expert that could review the syntax in this code? Specifically, how do you write a where-object cmdlet so that it matches PART of a string pattern, in this case, the old domain suffix for the Group email address.
ASKER
I think I pretty much have it:
$Groups = Get-UnifiedGroup | where {($_.PrimarySmtpAddress -match "<old_domain>")}
foreach ($Group in $Groups) {
>> $Alias = $Group.Alias
>> $Identity = $Group.Identity
>> $SMTP = $Alias + "@<new_domain>"
>> Set-Mailbox -Identity $Identity -EmailAddresses @{add="$SMTP"}
>> Set-Mailbox -Identity $Identity -PrimarySmtpAddress $SMTP
>>}
When I run this I'm getting the following error:
The operation couldn't be performed because object '$Identity' couldn't be found on
'<servername>.PROD.OUTLOOK .COM'.
It appears the Identity property is pulling a Guid of sorts, but even if I change the $Identity variable to collect the DisplayName or Alias property, it gives the same error.
Does somebody know why this happens?
$Groups = Get-UnifiedGroup | where {($_.PrimarySmtpAddress -match "<old_domain>")}
foreach ($Group in $Groups) {
>> $Alias = $Group.Alias
>> $Identity = $Group.Identity
>> $SMTP = $Alias + "@<new_domain>"
>> Set-Mailbox -Identity $Identity -EmailAddresses @{add="$SMTP"}
>> Set-Mailbox -Identity $Identity -PrimarySmtpAddress $SMTP
>>}
When I run this I'm getting the following error:
The operation couldn't be performed because object '$Identity' couldn't be found on
'<servername>.PROD.OUTLOOK
It appears the Identity property is pulling a Guid of sorts, but even if I change the $Identity variable to collect the DisplayName or Alias property, it gives the same error.
Does somebody know why this happens?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.