%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
- run a script that looks for the Preferences file for all the users of the device
- interpreters the Preferences file that is in the JSON format and dumps the information in a unique text file
- 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.
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/
Comments