If I run the script to add a new admin to a DL, it works fine:
$dl = ‘dl@abc.com’
$Admin = ‘admin@abc.com’
Set-DistributionGroup $dl -BypassSecurityGroupManagerCheck -ManagedBy((Get-DistributionGroup $dl).ManagedBy + $Admin)
But If I run this script to remove an admin it fails. I believe this worked in the past.
The error I get is “does not contain a method named ‘op_Subtraction’”
Set-DistributionGroup $dl -BypassSecurityGroupManagerCheck -ManagedBy((Get-DistributionGroup $dl).ManagedBy - $Admin)
How can I use powershell to remove an admin from a DL?
Thanks
[quote quote=197267]Loop not required, just check if the object is in the array
if ($list-notcontains (Get-RemoteMailbox$Admin_Alias).identity) {$NewList+=$list}
[/quote]
Thanks Rob. Unfortunately that does not remove the admin from the list. If the admin is in the list, all admins are stripped. Also I would still end up with 4 lines of code.