Office 365 – Exchange Online Forward Migration

Problem: That X has created around 200+ forwards that are linked to an external contact – exemployee@papu.com
However, exemployee@papu.com is mail account now.

1. What we need to write in the script is find all forwards where there is 0 membership
2. Add an exexmployee

Solution:

$amount = @()

## Get all distribution group for interpro.com.au
$groups = Get-DistributionGroup | where {$_.PrimarySmtpAddress -like “*@papu.com”}
## Loop through and add for exemployee@
foreach ($a in $groups)
{
$count = @()
$count = ([array](Get-DistributionGroupMember –identity $a.Identity)).Count
if ($count –lt 1 ) {
Add-DistributionGroupMember -Identity $a.Identity -Member “exemployee@papu.com”
Write-Output $a.Identity
}
}

 

References:

 

  • http://help.outlook.com/en-us/140/cc952755.aspx
  • http://community.office365.com/en-us/f/161/p/16010/73984.aspx#73984
  • http://help.outlook.com/en-gb/140/dd575549.aspx#DistributionGroups