/build/static/layout/Breadcrumb_cap_w.png

Get installed Google Chrome extensions

There was a Powershell script posted online that pulls Chrome extension information directly from the Chrome Web Store. That appears to be completely broken since the Web Store recently changed how the URL are written. I wrote this script that will pull all extension info locally from a couple JSON files within the user's profiles. You can set this script to run daily and pull in the information as a Custom Inventory Field, so you can see what extensions a user is using. This information is helpful when a user is having issues in their browser, or for identifying unwanted extensions. Because this script pulls in information for whoever is currently logged in when the script runs - it works best on 1 to 1 devices, not shared devices. 

You can also create a report for all your machines:
Fields: System Name, Chrome Extensions
Sort: System Name (Ascending)
Filter: Chrome Extensions is NOT NULL

Inventory Example:

kd6+O9ckLOAAAAAElFTkSuQmCC

Kace Script...

Under Kace scripting, create a new script.


[Configure]
Name: Chrome Browser Extensions (or whatever you want to name it)
Description: Pulls in Chrome browser extension names and versions
Enabled: Yes

[Deploy]
Operating Systems: Microsoft Windows (All)

[Windows Run As] 
Logged-in user 



[Schedule] 
Every day at 9:00 (or whatever you prefer)

[Schedule Options] 
Run on next connection if offline

[Dependencies] 
ChromeExtensions.ps1 (see bottom of post for script)


[Task 1]

Verify

 1. Verify a file exists...
   Directory: $(KACE_DEPENDENCY_DIR)
   File: ChromeExtensions.ps1

On Success
 1. Launch a program...
   Directory: $(KACE_SYS_DIR)\WindowsPowerShell\v1.0
   File: powershell.exe
   Parameters: -nologo -executionpolicy bypass -noprofile -file $(KACE_DEPENDENCY_DIR)\ChromeExtensions.ps1
   Visible / Wait for completion: [leave both unchecked]

Remediation
1. Log a message
     Type: Status
     Message: FAILED: Could not locate script file [ChromeExtensions.ps1]
2. Always Fail


Save the script.



Custom Inventory Rule...

Go to Inventory then Software
Choose Action -> New

Name: Chrome Extensions (or whatever you want to name it)
Notes: Displays information about installed Chrome extensions
Supported Operating Systems: Microsoft Windows (All)
Custom Inventory Rule: ShellCommandTextReturn(cmd /c type "C:\temp\ChromeExt.log")

1f5dYOOHTuG4cOHy0NEREREdLc4cOAARKaTh5quWUGQiIiIiO5OtzUIEhEREdGfC68RJCIiIjJTDIJEREREZopBkIiIiMhMMQgSERERmSkGQSIiIiIzxSBIREREZKYYBImIiIjMFIMgERERkZliECQiIiIyUwyCRERERGaKQZCIiIjITDEIEhEREZkpBkEiIiIiswT8f10y6ct1j5j0AAAAAElFTkSuQmCC

Save the software item.

Next time your script runs (whatever you scheduled it for) and log file is generated. When the machine checks in, Kace will automatically pull in that data and display it under Custom Inventory Fields.

Note: 'C:\temp' folder must exist on the client machines for this to work. if you don't want to use that folder, update the last line in the Powershell script and the Custom Inventory Rule software item in Kace to whatever path you want to use for the log file.

[ChromeExtensions.ps1] Script:

function Get-ChromeExtension {


# Set variables

$user = $ENV:USERNAME

$computer = $env:COMPUTERNAME

$appData = $ENV:LOCALAPPDATA


# Find Google Chrome extensions folder(s) for current user in User\AppData\Local\Google, pull in all sub folders

$extFolder = Get-childitem -Path "$appData\Google\Chrome" -Filter 'Extensions' -Directory -Recurse | %{$_.FullName}

$extensions = Get-ChildItem -Path $extFolder -Directory -ErrorAction SilentlyContinue


# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

# Loop through each extension folder

ForEach ($extension in $extensions) {


    $extensionFolderName = $extension.Name # Extension folder name

    $extensionPath = $extension.FullName # Full file path to that extension folder

    $extensionPathVer = Get-ChildItem -Path $extensionPath | Sort-Object -Property CreationTime -Descending | Select-Object -First 1  | %{$_.FullName}  # Get latest version of extension only

    $manifestContent= Get-ChildItem -Path $extensionPathVer -Filter 'manifest.json' | Get-Content -Raw | ConvertFrom-Json # Read manifest.json file to query extension info

    $extensionFolderNameMatch = $manifestContent.name  # Ext name

    $extensionDesc = $manifestContent.description      # Ext desc

    $extensionVersionMatch = $manifestContent.version  # Ext version


    # If generic MSG name or MSG description found, do additional query through messages.json file in '_locals\en' for more extension info

    if ($extensionFolderNameMatch -match '^__MSG_(.*)__' -or $extensionDesc -match '^__MSG_(.*)__') {

     $messages = Get-ChildItem -LiteralPath $extensionPathVer -recurse -Filter 'en' | Get-ChildItem -Filter 'messages.json' | Get-Content -Raw | ConvertFrom-Json


        if ($extensionFolderNameMatch -match '^__MSG_(.*)__') {

            $extensionFolderNameMatchTrim = $extensionFolderNameMatch.replace('__MSG_','').replace('__','')

            $extensionFolderNameMatch = $messages.$extensionFolderNameMatchTrim | Select-Object -ExpandProperty Message

            }


        if ($extensionDesc -match '^__MSG_(.*)__') {

            $extensionDescTrim = $extensionDesc.replace('__MSG_','').replace('__','')

            $extensionDesc = $messages.$extensionDescTrim | Select-Object -ExpandProperty Message

            }


        }


        # Create array of values for each extension found

        [PSCustomObject][Ordered]@{

            Name        = $extensionFolderNameMatch

            Version     = $extensionVersionMatch

            Description = $extensionDesc

            ID          = $extensionFolderName

            User        = $user

            Computer    = $computer

        }    


  # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!  

  # End of ForEach loop

  }


  # End Function

  }


  # Run the script and export to log file

  Get-ChromeExtension > "C:\Temp\ChromeExt.log"


Comments

This post is locked

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ