How to extract information from the Chrome preferences file and collect them with a K1000 Custom Inventory Rule

If you already had a look inside the Chrome folders on your Windows machine for sure you noticed that Chrome saves the preferences in a file under 

 %USERPROFILE%\AppData\Local\Google\Chrome\User Data\Default .

The file that contains the preferences is called Preferences and it is in JSON format.

The best approach to extract the information that we need from that file and collect them with a Custom Inventory Rule is 

  1. run a script that looks for the Preferences file for all the users of the device
  2. interpreters the Preferences file that is in the JSON format and dumps the information in a unique text file
  3. collect the file content with a Custom Inventory Rule

To interpreter the file we can use the PowerShell cmdlet ConvertFrom-Json that was introduced in PowerShell 3.0.

The following example extracts the default page(s) from the Preferences file found in all the users profiles and dumps the result in the file C:\Chromato.txt

This script extracts the default page from the Chrome preferences file for all the user of the computer.
 This script extracts the default page from the Chrome preferences for all the user of the device using the 
 ConvertFrom-Json cmdlet introduced in PowerShell 3.0
 AUTHOR:      Marco S. Zuppone for DELL KACE
  You will need PowerShell 3.0 or better
 WARNING: This script is given AS IS. Use it at your own risk! Revise it carefully before to use it.
Remove-Item c:\Chromato.txt
Get-ChildItem c:\users| 
where {$_.PsIsContainer} |
foreach {
$PrefFileName = $_.FullName+'\AppData\Local\Google\Chrome\User Data\Default\Preferences'
try {
$ch = ConvertFrom-Json -InputObject (Get-Content $PrefFileName -raw)
echo "-----------------" | Out-File -filepath c:\Chromato.txt -Append
Out-File -filepath c:\Chromato.txt -Append -InputObject ("User: "+$_.FullName)
Out-File -filepath c:\Chromato.txt -Append -InputObject $ch.session.startup_urls
echo "-----------------" | Out-File -filepath c:\Chromato.txt -Append
    catch {"File not there or not parsable at "+$PrefFileName}

You can easily modify the script above to exact the information that you want from the file: the object $ch contains all of them.

The custom inventory rule is the following:

ShellCommandTextReturn(cmd /c type c:\Chromato.txt)

You can execute periodically the PowerShell script on the devices from you want to obtain the Chrome settings information.

Remember to invoke it using PowerShell.exe -ExecutionPolicy Unrestricted  or otherwise to sign the script with a trusted certificate.

If you want to know more about how to sign a PowerShell script you can have a look to this article http://www.msz.it/how-to-sign-a-powershell-script/


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


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