locked
Updating Group ManagedBy details from another group RRS feed

  • Question

  • Hi,

    I am trying to update the Managed By information for a distribution group with the group members of another group. For example we have distribution group called SalesTeam and another group called Managers. Managers contains User A, User B and User C. What I am looking to do is get the users in the Managers group and set them as the managers (under the Managed By information) of SalesTeam. So far I have managed to get as far as the below:

    $Name = (get-ADGroupMember "Managers" | Select-Object -Expand Name) -join ","

    Set-DistributionGroup -Identity [group name] -BypassSecurityGroupManagerCheck -ManagedBy $name -ForceUpgrade

    The problem is when adding multiple users via the -ManagedBy parameter it needs to be in the following format:

    -ManagedBy User A, User B, User C

    Does anyone know how I get the members of the Managers group and change the output of that to be compatible with the format required to add multiple users?

    Thanks in advance!


    Monday, November 28, 2016 11:23 AM

All replies

  • Powershell works with objects. What you see in the console are usually serialized representations of object or arrays. Just pass the array you get from Get-ADGroupMember (without the -join part)  to your -ManagedBy parameter. It will work.

    Grüße - Best regards

    PS:> (79,108,97,102|%{[char]$_})-join''

    Monday, November 28, 2016 11:56 AM
  • Hi,

    This doesn't work as each user name passed to the -ManagedBy parameter overwrites the previous input leaving one manager rather than the three required.

    Kind Regards,

    Arnold

    Monday, November 28, 2016 12:02 PM
  • $Name = Get-ADGroupMember "Managers"
    Set-DistributionGroup -Identity [group name] -BypassSecurityGroupManagerCheck -ManagedBy $Name.Name -ForceUpgrade
    Monday, November 28, 2016 1:15 PM
  • The managedBy attribute is single valued. There can be only one manager, but it can be a group. It is also DN syntax.

    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    Monday, November 28, 2016 2:37 PM
  • ManagedBy is a multivalued property

    https://technet.microsoft.com/en-us/library/bb124955(v=exchg.160).aspx

    [-ManagedBy <MultiValuedProperty>]

    Monday, November 28, 2016 2:45 PM
  • Then Exchange must update the Schema for this attribute. In Active Directory it is single valued:

    https://msdn.microsoft.com/en-us/library/ms676857%28v=vs.85%29.aspx

    https://msdn.microsoft.com/en-us/library/cc220659.aspx


    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    Monday, November 28, 2016 2:50 PM
  • I thought that's the reason why you need a schema admin to install an Exchange system initially.

    Grüße - Best regards

    PS:> (79,108,97,102|%{[char]$_})-join''

    Monday, November 28, 2016 3:06 PM