locked
Bulk external users as members not as guest RRS feed

  • Question

  • Hi,

    I am trying this PowerShell script to import users from CSV (external emails) file into Azure AD:

    $invitations = import-csv list.csv
    foreach ($email in $invitations) {New-AzureADMSInvitation `
    -InvitedUserEmailAddress $email.email `
    -InvitedUserDisplayName $email.Name `
    -InviteRedirectUrl https://myapps.microsoft.com `
    -InvitedUserMessageInfo $messageInfo `
    -SendInvitationMessage $true
    }

    And the users are imported correctly but as Guests users and they couldn't login so I tried to change "User Type" from guest to member as the following but this give me an error:

    foreach ($user in $users){
    Write-Host $user.ObjectId
    Set-AzureADUser -ObjectId $user.ObjectId -UserType "member"
    }

    Is there a direct way to invite those user immediately as members and in this case they can login?

    B.R,

    /M


    • Edited by moh85 Monday, March 2, 2020 1:45 PM
    Monday, March 2, 2020 1:44 PM

All replies

  • Have they accepted the invitations?

    https://docs.microsoft.com/en-us/azure/active-directory/b2b/b2b-quickstart-add-guest-users-portal

    hth
    Marcin

    Monday, March 2, 2020 1:53 PM
  • I tried a test email and I received an email but when I clicked the invitation "Get started" the website redirected me to login and login didn't accept my email ex, @gmail.com?

    Thanks,

    Monday, March 2, 2020 2:21 PM
  • I gather this does match the account that specified when creating the invitation (and the one that received it) -correct?

    hth
    Marcin

    Monday, March 2, 2020 2:43 PM
  • if I understand your question correctly, Yes, I am dealing with the same email .. send an invitation to a specific email (PowerShell) and I received an invitation in that specific email then when I click url I cannot login with my email account!


    Tuesday, March 3, 2020 10:55 AM
  • As per https://docs.microsoft.com/en-us/azure/active-directory/b2b/b2b-quickstart-invite-powershell you should be running

    New-AzureADMSInvitation -InvitedUserDisplayName "username" -InvitedUserEmailAddress emailaddress -InviteRedirectURL https://myapps.azure.com -SendInvitationMessage $true

    hth
    Marcin


    Tuesday, March 3, 2020 12:49 PM
  • True and that what I have done, but it just accepts Azure external accounts or MS hotmail emails .. but it doesn't accept Gmail as an example!

    I have the following scenario:

    Web application hosted in Azure as web app and I want to import external Azure users to use it. I will implement this scenario as the following:

    - create registration app and use the created config like client_id or tenant_id in login code.

    - create a special Azure ad group and assign this group to this app (as enterprise app properties)

    - using Power Shell script to add users to this group as the following:

    $invitations = import-csv list.csv

    foreach ($email in $invitations)
       {New-AzureADMSInvitation `
          -InvitedUserEmailAddress $email.email `
          -InvitedUserDisplayName $email.Name `
          -InviteRedirectUrl https://myapps.azure.com `
          -InvitedUserMessageInfo $messageInfo `
          -SendInvitationMessage $true
       }

    $users = Get-AzureADUser -Filter "UserType eq 'Guest'"
    foreach ($user in $users){
    Add-AzureADGroupMember -ObjectId "Group Object ID" -RefObjectId $user.ObjectId
    }

    The previous scenario is for the first insertion of the users, now for every time I want to add / remove user I have to check two lists which are CSV file, that contains all actual users, and all the users who belong to this specific group then compare between them, after that I will update the users in this group to be exactly like CSV.

    Sorry for this long question and thanks for advance, 

    /M


    • Edited by moh85 Tuesday, March 3, 2020 5:02 PM
    Tuesday, March 3, 2020 5:01 PM
  • We're migrating from MSDN to Microsoft Q&A as our new forums and Azure WebApps & Azure Active Directory has already made the move! 

    To ease your transition experience, I have created a forum thread on Q&A https://docs.microsoft.com/answers/questions/11883/bulk-external-users-as-members-not-as-guest.html where one of our specialized engineers in the subject or the Azure community members can provide the best possible answer to your scenario or question.

    In future, you can ask and look for the discussion for Azure WebApps related questions here: https://docs.microsoft.com/answers/topics/azure-webapps.html

    In future, you can ask and look for the discussion for Azure Active Directory related questions here: https://docs.microsoft.com/answers/topics/azure-active-directory.html


    Tuesday, March 10, 2020 6:37 AM