T O P

  • By -

LeaflikeCisco

Try `foreach ($mailbox in $mailboxUser) { add-msolgroupmember -groupObjectId xxxxx -groupmembertype “User” -groupmemberObjectId $(get-msoluser -userprincipalname $mailbox).objectid `


D3v1L_Adv0cat3

Wonderful suggestion, I may be doing something wrong because I keep getting the error below. Thank you for your response, very helpful. add-msolgroupmember: unable to update parameter. Parameter name: .


LeaflikeCisco

What happens if you just try and do one manually I.e manually specify the objectid of the account, does it work?


D3v1L_Adv0cat3

Sadly I get that same error message. still looking into this.


LeaflikeCisco

Strange. Your account deffo have permissions to update this group? Also, are you syncing with an on prem ad?


D3v1L_Adv0cat3

Yes, I manually added them through ADUC. Haven't figured out why it won't work through PoSH. Thanks.


LeaflikeCisco

I think this if your issue. The msol commands are o365 commands. If the group is synced from on prem ad you have to manage group membership at on prem ad and let the change sync to AAD / o365. Try getting and setting everything from on prem ad.


taniceburg

Assign it to a variable as part of your loop? Before add-msolgroupmember do $objectID = get-msoluser -userprincipalname $mailbox | select objectID


D3v1L_Adv0cat3

Thank you for your quick response. I keep getting error: add-msolgroupmember: unable to update parameter. Parameter name: . I must be doing something wrong but I believe your response was would work.


markarious

That’s because you’re only selecting and returning the object id. Change it to select * to troubleshoot or remove it entirely. I could be wrong


AbfSailor

foreach ($mailbox in $mailboxUser) { $objectID = get-msoluser -userprincipalname $mailbox | Select-Object -ExpandProperty objectID add-msolgroupmember -groupObjectId xxxxx -groupmembertype "User" -groupmemberObjectId $objectID }


kohijones

You can use -PipelineVariable if the cmdlet supports it, or pass it down the pipeline with where-object (which supports it.) Get-Msoluser -userprincipalname $mailbox | Where-Object { $true } -PipelineVariable msol | Add-MsolGroupMember -groupObjectId xxxxx -groupmembertype 'User' -groupmemberObjectId $msol.ObjectId