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:

 C:\%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

 <# 
 .SYNOPSIS
This script extracts the default page from the Chrome preferences file for all the user of the computer.
 .DESCRIPTION
 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
 .NOTES       
  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.

I published this article on ITNjna as well. You can find it here
 
itninja.com