I would like to license a large number of people through a script.

주하 김 0 Reputation points
2023-02-08T07:49:38.8566667+00:00

I need to grant MS365 E3 licenses to several people. Can't I automate using the cloud power shell? If possible, can you provide a reference in Korean? Reference in English is also good.

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,362 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Shweta Mathur 27,141 Reputation points Microsoft Employee
    2023-02-09T08:32:30.0833333+00:00

    Hi @주하 김 ,

    Thanks for reaching out.

    I understand you are trying to assign license to bulk user using PowerShell script.

    Yes, it is possible to quickly assign licenses to unlicensed accounts which is required to access any Microsoft 365 services.

    Specify the location is the required part of assigning the licenses to the users.

    1. Create a CSV files with the userPrincipalName of the users you want to assign the licenses. User's image
    2. Copy and paste the powershell script in powershell window .
    3. Ensure to update the ‘usagelocation‘ & ‘SkuPartNumber‘ in the script. For Usage Location, Microsoft Follows A2 (ISO) format. SkuPartNumber is the available licensing plans for your organization. For example, ENTERPRISEPACK is the license plan name for Office 365 Enterprise E3.
       #Assigning and removing licenses for a user requires the User.ReadWrite.All permission scope
       Connect-MgGraph -Scopes User.ReadWrite.All, Organization.Read.All
       #Import data from csv file
       $users = import-csv "C:..\AssignLicence.csv"
       #Assign usage location and license based on upn in csv
       foreach ($user in $users)
       {
       $upn=$user.UserPrincipalName
       $usagelocation= "IN"
       Update-MgUser -UserId $upn -UsageLocation $usagelocation
       $e5Sku = Get-MgSubscribedSku -All | Where SkuPartNumber -eq '
       ENTERPRISEPACK'
       Set-MgUserLicense -UserId $upn -AddLicenses @{SkuId = $e5Sku.SkuId} -RemoveLicenses @()
       }
    

    Reference : https://learn.microsoft.com/en-us/microsoft-365/enterprise/assign-licenses-to-user-accounts-with-microsoft-365-powershell?view=o365-worldwide

    Hope this will help.

    Thanks,

    Shweta


    Please remember to "Accept Answer" if answer helped you.

    0 comments No comments