Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Install Chrome and create the registry key to trigger installation of Chrome extension.
This script installs Google Chrome by using Chocolatey and creates the registry key that will trigger the installation of the Chrome extension.
This script is created for usage with Microsoft Intune, which doesn't support parameters yet.
Author: Peter van der Woude
Date published: 02-07-2018
Current version: 1.0
#Set variables as input for the script
$ChocoPackages = @("googlechrome")
$ChocoInstall = Join-Path ([System.Environment]::GetFolderPath("CommonApplicationData")) "Chocolatey\bin\choco.exe"
$KeyPath = "HKLM:\Software\Policies\Google\Chrome\ExtensionInstallForcelist"
$KeyName = "1"
$KeyType = "String"
$KeyValue = "ppnbnpeolgkicgegkbkbjmhlideopiji;"
#Verify if Chocolatey is installed
if(!(Test-Path $ChocoInstall)) {
try {
#Install Chocolatey
Invoke-Expression ((New-Object net.webclient).DownloadString('')) -ErrorAction Stop
catch {
Write-Output "FAILED to install Chocolatey"
#Run through the required Chocolatey packages
foreach($Package in $ChocoPackages) {
try {
#Install Chocolatey package
Invoke-Expression "cmd.exe /c $ChocoInstall Install $Package -y" -ErrorAction Stop
catch {
Write-Output "FAILED to install $Package"
#Verify if the registry path already exists
if(!(Test-Path $KeyPath)) {
try {
#Create registry path
New-Item -Path $KeyPath -ItemType RegistryKey -Force -ErrorAction Stop
catch {
Write-Output "FAILED to create the registry path"
#Verify if the registry key already exists
if(!((Get-ItemProperty $KeyPath).$KeyName)) {
try {
#Create registry key
New-ItemProperty -Path $KeyPath -Name $KeyName -PropertyType $KeyType -Value $KeyValue
catch {
Write-Output "FAILED to create the registry key"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment