I'm trying to bulk move users from one group to another in a SharePoint online group. I ran this script:

enter image description here

And it moved only users that have O365 licenses. When it tried to move the other users, I got this error:

enter image description here

Am I only able to move users that have licensed accounts? Or is there something that I'm missing in the script? For what it's worth, I'm working inside of a GCC High tenant.

Any insight would be helpful!

1 Answer 1


If a user doesn't have an Exchange Online license, they won't have an Email address. This means that $User.Email will be blank. Try using $User.LoginName instead of $User.Email.

This would also mean you don't have to prepend i:0#.f|membership| to email to get $UserID. You can simply use Add-PnpGroupMember -LoginName $User.LoginName -Identity $DestinationGroupName

  • Awesome!! Thank you so much. I'll definitely remember that going forward when using other scripts.
    – Ryan
    Jul 12, 2023 at 22:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.