Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The License will get import on the target tenant or not #2556

Closed
rakeshsujan opened this issue Nov 18, 2022 · 8 comments · Fixed by #2574 or #2584
Closed

The License will get import on the target tenant or not #2556

rakeshsujan opened this issue Nov 18, 2022 · 8 comments · Fixed by #2574 or #2584
Assignees
Labels
Bug Something isn't working Entra ID

Comments

@rakeshsujan
Copy link

Details of the scenario you tried and the problem that is occurring

Verbose logs showing the problem

Suggested solution to the issue

The DSC configuration that is used to reproduce the issue (as detailed as possible)

# insert configuration here

The operating system the target node is running

Version of the DSC module that was used ('dev' if using current dev branch)

@andikrueger
Copy link
Collaborator

Could elaborate a bit more, what this question is about? Thanks!

@rakeshsujan
Copy link
Author

I want to import the configuration from source tenant to target tenant in that situation for user the License, user attributes, user member group also will get import or not?

@andikrueger
Copy link
Collaborator

There won’t be any licenses transferred from your source Tenant to the target tenant.

The objects within the tenant depend on what you did export and therefore this will also determine what is going to be created/updated within your target tenant.

@rakeshsujan
Copy link
Author

If i exported the Azure AD from source tenant and same thing i am importing into target tenant for user the License, user attributes, user member group will get assign or not.

Because when i check the export configuration of source tenant i can see the user License details, user attributes etc., but when i try to import the same configuration in target tenant only the user it's get creating.

Can you help me on this. I have attached screenshot for your reference.

image

@andikrueger
Copy link
Collaborator

If you do have the same SKUs within your target tenant, M365 would try to assign the licenses to the user. If M365DSC is not able to find any licenses within the target tenant, no license assignment will happen.

This is the code, that would look for license:

 #region Licenses
        if ($LicenseAssignment -ne $null)
        {
            [Array] $currentLicenses = $user.LicenseAssignment
            if ($null -eq $currentLicenses)
            {
                $currentLicenses = @()
            }
            $licenseDifferences  = Compare-Object -ReferenceObject $LicenseAssignment -DifferenceObject $currentLicenses
            if ($licensesDifferences.Length -gt 0)
            {
                $licenses = @{AddLicenses = @(); RemoveLicenses = @();}

                $SubscribedSku = Get-MgSubscribedSku
                foreach ($licenseSkuPart in $LicenseAssignment)
                {
                    Write-Verbose -Message "Adding License {$licenseSkuPart} to the Queue"
                    $license = @{
                        SkuId = ($SubscribedSku | Where-Object -Property SkuPartNumber -Value $licenseSkuPart -EQ).SkuID
                    }

                    # Set the Office license as the license we want to add in the $licenses object
                    $licenses.AddLicenses += $license
                }

                foreach ($currentLicense in $user.LicenseAssignment)
                {
                    if ($LicenseAssignment -and -not $LicenseAssignment.Contains($currentLicense))
                    {
                        Write-Verbose -Message "Removing {$currentLicense} from user {$UserPrincipalName}"
                        $license = @{
                            SkuId = ($SubscribedSku | Where-Object -Property SkuPartNumber -Value $currentLicense -EQ).SkuID
                        }
                        $licenses.RemoveLicenses += $license
                    }
                }
            }
        }
        #endregion

@rakeshsujan
Copy link
Author

I replaced the SKU that is available in target tenant to assign to the user.

image

Exported source configuration screenshot is as below.

image

Modified in MOF file the screenshot is below.(replaced the SKU that existing in target tenant)

image

Still the license is not getting assigned on the target tenant.

Also noticed the licensed assignment function is getting pushed before getting the user. (logically it's not possible)

Manually i can modify for 1 or 2 users and also can add delay/wait in between creating user and license assignment but what if there are bulk users?

@andikrueger
Copy link
Collaborator

I just checked the code and the order of the operations is correct. Could you have a look at your event log to see, if something is reported there?

The user is created in line 484-501. License assignment will take place in lines 504-535.

@rakeshsujan
Copy link
Author

But in the event log file i could not find anything wrong or it's marked as error or warning.

The below mentioned screenshot says that License assignment is empty even if i mark the correct license details in MOF file.

image

NikCharlebois added a commit to NikCharlebois/Microsoft365DSC that referenced this issue Nov 22, 2022
@NikCharlebois NikCharlebois added Bug Something isn't working and removed Pending Information labels Nov 22, 2022
@NikCharlebois NikCharlebois self-assigned this Nov 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Entra ID
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants