Worklet: Install Chrome for Windows

  • 18 October 2019
  • 2 replies
  • 13 views

Userlevel 7
  • Novice
  • 1507 replies

This worklet installs Chrome on Windows.


Evaluation code:


#REQUIRES -Version 2.0
<#
.SYNOPSIS
This Test script checks to see if Chrome is installed
.DESCRIPTION
This script queries the installed files for 32 and 64bit software
and returns a 0 if product is installed or 1 if not
.Notes
File Name :Chrome_Install_Test.ps1
Author :Automox
Prerequisite :PowerShell V2 over win7 and upper
#>
#Handle Exit Codes:
trap { $host.ui.WriteErrorLine($_.Exception); exit 90 }

function Chrome_Install_Test {
#Get 32 bit software
$32BIT=Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName | select-string 'Chrome' | out-string
#check 64 bit
$64BIT=Get-ItemProperty HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName | select-string 'Chrome' | out-string

if ($32BIT.Trim() -match "Displayname=Google Chrome" -Or $64BIT.Trim() -match "Displayname=Google Chrome") {
exit 0
}
else {
exit 1
}
}
Chrome_Install_Test

Remediation code:


#REQUIRES -Version 2.0
<#
.SYNOPSIS
This script allows an admin to install Google chrome.
.DESCRIPTION
This script downloads the installer into c://Temp, executes it silently, and cleans up.
This is an example script that has been tested to work on Win10 and Win7.
This script may not work on all systems. Modify to fit your needs
.NOTES
File Name :Chrome_Install.ps1
Author :Automox
Prerequisite :PowerShell V2 over win7 and upper
#>
#Handle Exit codes:
trap { $host.ui.WriteErrorLine($_.Exception); exit 90 }

function Chrome_Install{
#############Change the settings in this block#######################
$Save_Dir="c:\\Windows\Temp"
$URL="https://dl.google.com/chrome/install/375.126/chrome_installer.exe"
#####################################################################
Try {
(new-object System.Net.WebClient).DownloadFile("$URL", "$Save_Dir\chrome_installer.exe")
Start-Process "$Save_Dir\chrome_installer.exe" -Wait
Remove-Item "$Save_Dir\chrome_installer.exe"
exit 0
}
Catch {
exit 1
}
}

Chrome_Install

2 replies

Userlevel 2

Any worklet to uninstall Chrome?

Any worklet to uninstall Chrome?

I agree - any install script should also come with an uninstall script.

Reply