Add external users in a Site using PowerShell with MFA

Tanmoy Das 66 Reputation points


I need a ps script to add external users in SP site with MFA. Can anyone please share if they have one working?


A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,075 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Rijwan Ansari 746 Reputation points MVP


    You can try below script:

    #Setup Credentials to connect  
    Connect-SPOService -Url $AdminCenterURL -Credential (Get-Credential)  
    #add guest user to sharepoint online site  
    Add-SPOUser -Group "Marketing Visitors" -LoginName "" -Site ""  

  2. Haoyan Xue_MSFT 21,401 Reputation points Microsoft Vendor

    Hi @Tanmoy Das ,
    You can try below script to add External User to SharePoint Online Site:

    #Site Variables  
    $SiteURL = ""  
    $GroupName = "group2"  
    $ExternalUserEmail = ""  
    #Connect to PnP Online  
    Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)  
    #PowerShell to Add External User to group  
    Add-PnPGroupMember -Identity $GroupName -EmailAddress $ExternalUserEmail -SendEmail  

    The running result is as shown below:

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.