Google Workspace Frontline - Bulk Remove Licenses via Apps Script

Hey Google Admins, this is Goldy again, welcome to Google Workspace Frontline Worker video series.

In this video I'll show you how you can bulk remove Google frontline licenses from your users. maybe you have a lot of attrition or there is a use case where you need to remove frontline worker licenses in bulk. This video might help, we will be leveraging Google Apps script for it.

I'll just show you a static way where you can put the list of users in Google sheet and the script will run picking users one by one to remove their frontline worker license.

So as you see below, I have couple of users in my 'CI Only' organizational unit where I have them assigned Frontline worker license, and I will be using Google Apps script to remove frontline licenses from them.

1. There are two Users 1st is ok sir in CI Org Unit it has Frontline User License Assigned

I'll go to to create a new Google sheet, let's call it FLW. You can be more descriptive than what I did here.

3. Lets go to Sheets will Create a Sheet and lets call it a FLW

Then you will click on extensions, go to Apps script. Under Apps script let's name our sheet (may be flw remove).

4. Under add Skript Lets name our Sheet may be FLW

Now delete the default function that you see here, and copy the script below, and then paste it.


function assignLicenses() {

   // Add SKU details here, below ones are for frontline worker
   var productId = "Google-Apps"
   var skuId = 1010020030

   // Get Google Sheet and read the user emails from it, we'll use these to assign licenses

   var assignmentSheet = SpreadsheetApp.getActive().getSheetByName("Assign Frontline Licenses")
   var data = assignmentSheet.getRange(2, 1, assignmentSheet.getLastRow() - 1, 2).getValues()

   // Create an array to store the results from API, instead of appendRow, we'll rather save output to this array, and then write back to sheet at once
   var fileArray = [
       ["License Assignment Status"]

   // Loop through the google sheet values, and call License API to assign the given license
   data.forEach(function(item) {
       var status = "Licese Assigned Successfully"
       try {
           //var productId = getSkuDetails(item[1])
           var apiCall = AdminLicenseManager.LicenseAssignments.insert({
               "userId": item[0]
           }, productId, skuId)

       // Catch Errors (if any)
       catch (e) {
           var status = e.message

       // Write the output data back to our array

   // Write the results from array to our google sheet
   assignmentSheet.getRange(1, 2, fileArray.length, fileArray[0].length).setValues(fileArray)


It would look like the below screenshot now.

5.Here Delete all the Default Function and Going to paste that Script that copy from the website

Let's change the sheet name (at the bottom as shown in screenshot below) to "Remove Licenses" as this is what we have in the script, if you want to leave it sheet1 or any other name, then make sure to change it in the script also (watch the video above for more clarity).

Now, add two columns to the sheet (i) User Email Address, and (ii) Status
you would be putting the email address of the users from whom you want frontline license to be removed, you can leave the status column empty as our script will fill it up automatically with the status.

8. Come Back to this Sheet and Rename it and call it Remove Licenses So it can Find That Sheet and data

I have only added couple of users for this demonstration, but you may add a few hundreds too.

Now, go back to your Apps Script, click on "Services" on the left, then click on + icon, and add Admin Enterprise License Manager API service (as shown in screenshot below), as we'll use this to remove frontline worker licenses from the given users, finally click on "Add" blue button.

9. Under Services Click on Plus you will Find Enterprises License Manager API

Now, let us run our script by clicking on "Run" button as you see in the screenshot below.

11. then Click on save and Add it Now Lets Run it this is the First time So Script will ask for Authorization

Apps script will need your permission when you run it for the first time, click on review permissions to review.

12. We Will Approve to Review Permission

Make sure the address you using to authorize the script has required permissions to delete licenses.

13. Now Give it the Admin Id

You can read more about the permissions required by clicking on the bubble icon. If you're satisfied, click allow.

14. Give the admin Id read more about the Permissions . If You satisfied click On Allow

Now if you go back to the sheet, you would notice license update status is changed to "License Updated Successfully" or "License Removed Successfully".

15. Lets Go Back to my Sheet and It said License Updated Successfully

Let us confirm that by looking for these users licenses in Google Workspace admin console, I see that the frontline license has been removed from the user.

17. Now See its not Assigned anymore

Same for the second user, Google Workspace frontline license has been removed from this user too, which means our script is working fine.

19. Lets Look At The Ok the First one Same Process and See Different Line is gone from here Too

Now, actually you can use this script to remove any license from the given users, just by changing couple of properties in the script.

example - go to Google Enterprise license manager API , copy the product and sku-id of the license that you want to remove.

24. Here You will Find Google Products and SKU ids

Update the script with it, and that is it.

26. Now We Just Need to Enter these two Things Product Id And Sku Id

Then, simply add your users as you did to remove frontline licenses, then run the script and this time it will delete the license that you have put in the script.

30. all Those users that we have Put Here With Enterprises License Their License Will be Removed

I hope that this was helpful to delete Google Workspace Frontline worker license in bulk, in case if you have any questions, comments or feedback do not hesitate to put that below, and i'll be happy to collaborate.

Related Posts