(Cloud) Tip of the Day: Bulk license assignment

Today’s (Cloud) Tip…

You have learned lots about license management using PowerShell. Now you are thinking, how can I apply this to many users instead of one at a time…

Assign licenses to a group

IMPORTANT This will not automatically assign licenses to new members of the group

  1. First, you will need the Group Object ID. If you know the display name or email of the group, use the SearchString parameter of Get-MsolGroup. Only groups with a display name or email address starting with this string will be returned.
    Get-MsolGroup -SearchString "Display Name or email of Group"
  2. To review what licenses are assigned to the members of the group, you can use the following similar command line…
    Get-MsolGroupMember -GroupObjectId GroupObjectID | Get-MsolUser | Select UserPrincipalName, Licenses
  3. Set up your license options if any and assign the licenses to the current members of the group…
    Get-MsolGroupMember -GroupObjectId GroupObjectID | Set-MsolUserLicenses -AddLicenses woodgrovebank:ENTERPRISEPACK -LicenseOptions $options

For best experience, you may want to assign the license first to those who don't already have one, then later disable the plans, like so…

  • Get-MsolGroupMember -GroupObjectId GroupObjectID | Get-MsolUser | Where {$_.Licenses.AccountSkuId -notcontains "woodgrovebank:ENTERPRISEPACK"} | Set-MsolUserLicenses -AddLicenses woodgrovebank:ENTERPRISEPACK
  • Get-MsolGroupMember -GroupObjectId GroupObjectID | Set-MsolUserLicenses -LicenseOptions $option

        4.    Verify that the licenses are assigned to the members of the group
               Get-MsolGroupMember -GroupObjectId GroupObjectID | Get-MsolUser | Select UserPrincipalName, Licenses

Assign licenses to a list of users in a CSV file

  1. Create a CSV file that looks something like this and save it as users.csv…

      2.     And run the following similar command line based on your new knowledge.

              Import-CSV "users.csv" | Set-MsolUserLicenses -AddLicenses woodgrovebank:ENTERPRISEPACK -LicenseOptions $options

For best experience, you may want to assign the license first to those who don't already have one, then later disable the plans, like so…

  • Import-CSV "users.csv | Get-MsolUser | Where {$_.Licenses.AccountSkuId -notcontains "woodgrovebank:ENTERPRISEPACK"} | Set-MsolUserLicenses -AddLicenses woodgrovebank:ENTERPRISEPACK
  • Import-CSV "users.csv | Set-MsolUserLicenses -LicenseOptions $options

      3.     Verify that the licenses are assigned to the users in the list…                
              Import-CSV "users.csv" | Get-MsolUser | Select UserPrincipalName, Licenses