Play Video about 0. Google Workspace Frontline - Bulk Remove Licenses via Apps Script

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 sheets.new 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 updateLicenses() {

    // get access to our google sheet and read the users from whom we need to delete google frontline worker sku
    const updateSheet = SpreadsheetApp.getActive().getSheetByName("Remove Licenses")
    const data = updateSheet.getRange(2, 1, updateSheet.getLastRow() - 1, 3).getValues()
    const fileArray = [
        ["License Update Status"]
    ]

    // call license manager api to delete flw from above users, and push to the results to array
    data.forEach(function(item) {
        let status = "Licese Removed Successfully"
        try {
            const userId = item[0]
            const apiCall = AdminLicenseManager.LicenseAssignments.remove("Google-Apps", "1010020030", userId)


        } catch (e) {
            status = e.message
        }
        fileArray.push([status])
    })

    // write back results to our sheet
    updateSheet.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.

RECOMMENDED READING

As you just read Google Workspace Frontline – Bulk Remove Licenses via Apps Script, I would recommend following as complimentary reading.
Google Workspace to Office 365 SSO & Provisioning Guide
AdminGoogle WorkspaceSecuritySSO

Google Workspace to Office 365 SSO and Provisioning Guide

Read More →
Okta - Google - Integration - Guide
AdminGoogle WorkspaceSecuritySSO

Definitive Guide to Okta & Google Integration

Read More →
Google Workspace Password Vaulted Apps
AdminGoogle WorkspaceSecuritySSO

Securely login to any app with Google Workspace Password Vaulted Apps

Read More →

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top