Search code examples
excelazurepowershellazure-active-directoryazure-powershell

Azure AD users are not moving to license group automatically


I have created Dynamic Group for assigning License to All Azure AD user automatically using powershell in production Environment.

Here is my script:

`New-AzureADMSGroup -DisplayName "us_demo_group" -Description " your Descriptions-MailEnabled $False -MailNickName "group" -SecurityEnabled $True -GroupTypes "DynamicMembership" -membershipRule "(user.department -contains ""Marketing"")" -membershipRuleProcessingState "On"

Add-AADGroupLicenseAssignment -groupId "a5e95316-1c03-44d7-afac-efd0e788122c" -accountSkuId "your skuid:FLOW_FREE" `

My script is working fine, but when I tried to create a bulk users using Excel File, Users are not getting License, always showing **No License assignment Found **.

Any help is appreciated.


Solution

  • I tried to reproduce the same in my environment to assign the license to Azure AD user dynamically using power shell

    I have created Azure dynamic group using powerShell, name-TestGroup1 with condition.

    #Install  AzureADLicensing Module
    Install-Module -Name AzureADLicensing
    #Import AzureADPreview
    Import-Module AzureADPreview
    #Connect to Azure AD
    Connect-AzureAD
    New-AzureADMSGroup -DisplayName "TestGroup1" -Description "This group contains information of users from us domain" -MailEnabled $False -MailNickName "group" -SecurityEnabled $True -GroupTypes "DynamicMembership" -membershipRule "(user.department -contains ""Finance"")" -membershipRuleProcessingState "On"
    

    enter image description here

    TestGroup1 created once execute the above code.

    enter image description here

    Assign the license to group, like below

    #Get All License with SKUID
    Get-AADGroupLicenseAssignment -All
    

    You can fetch the group ID, like below.

    enter image description here

    #Assign License to Group
    Add-AADGroupLicenseAssignment -groupId "GroupIDObject ID" -accountSkuId "Your SKUID"
    

    enter image description here

    enter image description here

    Create bulk user in Azure Active Directory, like below.

    Azure Portal > Default Directory > Users > Bulk Operations > Bulk Create

    Make sure mention the department value for moving the users to dynamic group automatically.

    Download the excel file and add the value in excel and save, like below.

    enter image description here

    Once add the value in excel and Upload the excel to Azure, like below.

    enter image description here

    Successfully created bulk- users with license in Azure AD.

    enter image description here

    You can view the users in assigned group.

    enter image description here

    License assigned to group users automatically.

    enter image description here

    Successfully assigned Azure license to created users.

    enter image description here