No one has responded to this discussion for at least a year, so this information may be out of date. If you're looking for information about this topic, please search for a more recent discussion or post a new question.

Can't remove manager from DL in EMS

This question is answered This question is answered

One of our users is manager for many DLs and I need to remove her. I tried to do that with the Subtraction method:

$mydl = Get-DistributionGroup website
$mydl.managedby
eurprd04.prod.outlook.com/Microsoft Exchange Hosted Organizations/tenant.onmicrosoft.com/usera
eurprd04.prod.outlook.com/Microsoft Exchange Hosted Organizations/tenant.onmicrosoft.com/userb
$mydl.managedby -= "eurprd04.prod.outlook.com/Microsoft Exchange Hosted Organizations/tenant.onmicrosoft.com/usera"

Error:
Method invocation failed because [System.Collections.ArrayList] doesn't contain a method named 'op_Subtraction'.
At line:1 char:19
+ $mydl.managedby -= <<<< "eurprd04.prod.outlook.com/Microsoft Exchange Hosted Organizations/tenant.onmicrosoft.com/usera"
+ CategoryInfo : InvalidOperation: (op_Subtraction:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound

 

This works in on-premises Exchange 2010 SP2 environments but not in Exchange Online. Could this be an RBAC issue maybe? Can someone recommend a workaround maybe?

Verified Answer
  • Hi Jetze,

    Thanks for your update.
    Would you please run the following cmdlets to remove the usera and see if it works?
    $OwnerList=(Get-DistributionGroup "website").ManagedBy
    $OwnerList.Remove(eurprd04.prod.outlook.com/Microsoft Exchange Hosted Organizations/tenant.onmicrosoft.com/usera)
    Set-DistributionGroup “website" -ManagedBy $OwnerList

    Thanks,
    Grace Shi

All Replies
  • Hi Jetze,

    Thanks for posting here.
    From your description, I understand that you would like to remove one user from your description lists. Is it right?
    If it is true, we may remove the user in Exchange Control Panel.
    1. Log on the Office 365 Admin Home Page portal.microsoftonline.com with your user name and password, and then click the Exchange Online Manage button.
    2. In the Exchange Control Panel, select Manage My Organization > Users & Groups > Distribution Groups.
    3. double-click the distribution group that you want to edit, and locate the Ownership section, then remove the users.

    More information about distribution group, please see the article below:
    http://help.outlook.com/en-us/140/ms.exch.ecp.newdistributiongroup.aspx

    If there is any misunderstanding or you have any unclear information, please feel free to post in the forum.

    Thanks,
    Grace Shi

  • Thank you for your answer. I'm afraid I forgot to mention I need to do this programmatically, that's why I use PowerShell.

  • Hi Jetze,

    Thanks for your update.
    You may run the command: Set-DistributionGroup to remove the specific owner.

    In your situation, please run the cmdlet below:
    Set-DistributionGroup -Ideneity website -ManagedBy userb

    More information about the available cmdlets in Exchange Online service, please refer to the article below:
    http://help.outlook.com/en-us/140/dd575549.aspx

    Thanks,
    Grace Shi

  • That is the command to set a specific manager, this will overwrite all other managers. I need to use the command to remove a single manager from many DL's which have two ore more managers currently.

    Plase have a look again at the code I showed, this works on on-premises Exchange 2010 with the Organization Admin RBAC role but does not work in Exchange Online.

  • Hi Jetze,

    Thanks for your update.
    Would you please run the following cmdlets to remove the usera and see if it works?
    $OwnerList=(Get-DistributionGroup "website").ManagedBy
    $OwnerList.Remove(eurprd04.prod.outlook.com/Microsoft Exchange Hosted Organizations/tenant.onmicrosoft.com/usera)
    Set-DistributionGroup “website" -ManagedBy $OwnerList

    Thanks,
    Grace Shi

  • Hi Jetze,

    How are things going? Is there any update on the status of the issue?

    Thanks,

    Grace Shi

  • I needed to enclose the part between the brackets in quotation marks, but that makes sense of course. It works exaclty as I wanted it to do.

    $OwnerList=(Get-DistributionGroup "website").ManagedBy
    $OwnerList.Remove("eurprd04.prod.outlook.com/Microsoft Exchange Hosted Organizations/tenant.onmicrosoft.com/usera")
    Set-DistributionGroup “website" -ManagedBy $OwnerList

    Thanks for your help!