Powershell to Add an owner to O365 group failing RRS feed

  • Question

  • Trying to run a seemingly simple Set-Group command and it's failing and I have no idea why. In the Set-Group Technet page it says the below...

    To add or remove owners without affecting other existing entries, use the following syntax: @{Add="owner1","owner2"...; Remove="owner3","owner4"...}.

    But when running the below it fails...

    set-group -Identity "O365Group" -ManagedBy @{Add="User1","User2"}

    Fails with this error...

    Cannot process argument transformation on parameter 'ManagedBy'. Cannot convert value "System.Collections.Hashtable" to type "Microsoft.Exchange.Configuration.Tasks.GeneralRecipientIdParameter[]". Error: "Cannot convert value "System.Collections.Hashtable" to type "Microsoft.Exchange.Configuration.Tasks.GeneralRecipientIdParameter". Error: "Cannot convert hashtable to an object of the following type: Microsoft.Exchange.Configuration.Tasks.GeneralRecipientIdParameter. Hashtable-to-Object conversion is not supported in restricted language mode or a Data section."" + CategoryInfo : InvalidData: (:) [Set-Group], ParameterBindin... mationException + FullyQualifiedErrorId : ParameterArgumentTransformationError,Set-Group + PSComputerName : outlook.office365.com

    Any idea why this is failing? Using the UPN for the users & on Powershell V5

    Monday, November 27, 2017 5:03 PM


All replies

    • Marked as answer by JimBeam5 Wednesday, November 29, 2017 2:28 PM
    Monday, November 27, 2017 8:51 PM

  • Yeah I saw this yesterday but thought it was a bit strange that they needed to be added as members to make them owners. Doesn't really explain why Set-Group doesn't work as intended even though it says you're able to do it on the Technet article.

    Tuesday, November 28, 2017 9:46 AM
  • Hi,

    Based on the test in my lab, the same behavior is reproduced. In this case, I recommend using Set-DistributionGroup. In addition, you may also have a try with the following command to set the group manager directly, for your reference:
    Set-Group -Identity 'O365Group' -ManagedBy 'User1','User2'

    If you need further help, please feel free to let us know.

    Best Regards,
    Albert Ling

    Please remember to mark the replies as an answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Wednesday, November 29, 2017 6:49 AM
  • You need to use the Add-UnifiedGroupLinks cmdlet to add members and owners to an Office 365 group.  Owners must be members prior to making them owners.
    Wednesday, November 29, 2017 7:08 AM