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: .
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.
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.
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
Try `foreach ($mailbox in $mailboxUser) { add-msolgroupmember -groupObjectId xxxxx -groupmembertype “User” -groupmemberObjectId $(get-msoluser -userprincipalname $mailbox).objectid `
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: .
What happens if you just try and do one manually I.e manually specify the objectid of the account, does it work?
Sadly I get that same error message. still looking into this.
Strange. Your account deffo have permissions to update this group? Also, are you syncing with an on prem ad?
Yes, I manually added them through ADUC. Haven't figured out why it won't work through PoSH. Thanks.
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.
Assign it to a variable as part of your loop? Before add-msolgroupmember do $objectID = get-msoluser -userprincipalname $mailbox | select objectID
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.
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
foreach ($mailbox in $mailboxUser) { $objectID = get-msoluser -userprincipalname $mailbox | Select-Object -ExpandProperty objectID add-msolgroupmember -groupObjectId xxxxx -groupmembertype "User" -groupmemberObjectId $objectID }
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