Category filter

Script to manage Google Chrome extensions on Windows devices

Chrome extensions extend the capabilities of the Google Chrome web browser by improving its functionality and customization. The vast repository of extensions eases our daily chores, from optimizing schedules to blocking unwanted ads. Using Hexnode, you can remotely deploy various custom scripts that let you manage the use of various Chrome extensions on your Windows devices.

Disclaimer:

The Sample Scripts provided below are adapted from third-party Open-Source sites.

Install Chrome extensions

The script creates a registry key entry in the HKLM key path HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome\ExtensionInstallForcelist. The ExtensionInstallForcelist policy can be used to specify a list of extensions that install without user interaction and which users can’t uninstall or turn off. For example, the below scripts install the Google Hangouts extension.

To locate the extension ID, open the Chrome Web Store and search the name of the Google Chrome extension you intend to install. You can find the ID as a long string of characters at the end of the URL.

Ex: Google Hangouts ID: nckgahadagoaajjgafhacjanaoiihapd

PowerShell Script (.ps1)

Replace the ID in the script with the ID of the extension you want to install and ‘GoogleHangouts’ with the name of your extension.

Batch Script (.bat)

In the script, provide a name for the key in place of ‘1’ and replace nckgahadagoaajjgafhacjanaoiihapd with the extension ID you intend to install.

Remove Chrome extensions

The script below removes the registry entry with the key name ‘1’. Since there is already a key with the name ‘1’ that force installs the Google Hangouts extension, this script removes that key and thus the Google Hangouts extension.

Once the script is run successfully, the installed extensions will be removed from the device. Although please note that the users are free to install the removed extension later.

PowerShell Script (.ps1)

Block Chrome extensions

The script below creates a registry key entry in the HKLM key path HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome\ExtensionInstallBlocklist. The ExtensionInstallBlocklist policy allows you to specify which extensions cannot be installed by the user. Extensions already installed will be disabled if added to the block list, and the users cannot enable them.

Once the script below is run successfully, users cannot install the specified extensions. If the extensions are already installed, they will be blocked, and the users will be restricted from enabling them. For instance, the below script blocks the Google Hangouts extension.

PowerShell Script (.ps1)

Replace the name (‘GoogleHangouts’) and value (‘nckgahadagoaajjgafhacjanaoiihapd’) in the script with the name and ID of the extension you intend to remove. Set the value as * to block all the extensions.

Batch Script (.bat)

In the script, provide a name for the key instead of ‘1’ and replace nckgahadagoaajjgafhacjanaoiihapd with the ID of the extension you want to block.

Allow Chrome Extensions

All extensions are allowed by default. However, if the value is set as * in the ExtensionInstallBlocklist policy of the Windows registry, all the extensions will be blocked. The script below creates a registry key entry in the HKLM key path HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome\ExtensionInstallAllowlist to allow users to access only the specified extensions. For instance, the below script allows access to the Google Hangouts extension by creating a new key in the windows registry.

PowerShell Script (.ps1)

Replace the ID in the script with the ID of the extension you want to allow and ‘GoogleHangouts’ with the name of your extension.

Batch Script (.bat)

Provide a key name in place of ‘1’ and the extension ID you want to allow in place of nckgahadagoaajjgafhacjanaoiihapd.

Notes:

  • Note that the ExtensionInstallForcelist policy overrides the ExtensionInstallBlocklist policy.

    For instance, suppose you have configured a list of blocklisted extensions using the ExtensionInstallBlocklist policy. It restricts the specified extensions on the devices, thus preventing the users from accessing/installing them.

    Further configuring a force list of extensions using the ExtensionInstallForcelist policy for the same list of extensions makes them accessible to the users. If they are not already installed, silent installation proceeds, and they will no longer be restricted on the device.

  • It is recommended to manually validate the script execution on a system before executing the action in bulk.
  • Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.

  • Sample Script Repository