Monday, April 20, 2020

Chrome: Disabling Auto Update using PowerShell

In a previous post (Chrome: Disabling Auto Update using RegEdit), it was shown how to prevent Chrome from auto updating by editing registry using RegEdit. The point of this series of posts is to automate administrative tasks. In this post it will be shown how to disable Chrome from auto updating using PowerShell to update the registry.

To recap the steps required to disable Chrome auto updating are as follows:

1) Insure the following registry key exists and if it does not exist, create it:
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google

2) Insure the following registry key exists and if it does not exist, create it:
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Update

3) Insure the AutoUpdateCheckPeriodMinutes registry value exists with a value of zero under the  previous key:
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Update

The code to perform this is as follows:

[string] $softwarePolicyPath = 'HKLM:\SOFTWARE\Policies'
[string] $googleKey = 'Google'
[string] $googleUpdateKey = 'Update'

[string] $autoUpdateCheckPeriodMinutesValueName = 
             'AutoUpdateCheckPeriodMinutes'
[int] $autoUpdateCheckPeriodMinutesValue = 0
# If you are using pre-PowerShell 6.0 use this line of code instead

# [string] $softwarePolicyGoogleUpdatePath = 
#     Join-Path `
#         -Path $softwarePolicyPath `
#         -ChildPath $googleKey
[string] $softwarePolicyGooglePath = Join-Path $softwarePolicyPath $googleKey


if (-not (Test-Path $softwarePolicyGooglePath)) {
    Write-Host "Creating: $SoftwarePolicyGooglePath"

    New-Item `
        -Path $softwarePolicyPath `
        -Name $googleKey | Out-Null
}

# If you are using pre-PowerShell 6.0 use this line of code instead
# [string] $softwarePolicyGoogleUpdatePath = 
#     Join-Path `
#         -Path $SoftwarePolicyGooglePath `
#         -ChildPath $googleUpdateKey
[string] $softwarePolicyGoogleUpdatePath = Join-Path $softwarePolicyGooglePath $googleUpdateKey

if (-not (Test-Path $softwarePolicyGoogleUpdatePath)) {
    Write-Host "Creating: $softwarePolicyGoogleUpdatePath"

    New-Item `
        -Path $softwarePolicyGooglePath `
        -Name $googleUpdateKey | Out-Null
}

# create or update
Set-ItemProperty `
    -Path $softwarePolicyGoogleUpdatePath `
    -Name $autoUpdateCheckPeriodMinutesValueName `
    -Value $autoUpdateCheckPeriodMinutesValue


The Join-Path cmdlet shown above was reviewed in the previous post, PowerShell: Join-Path Joining Multiple Children.

The following cmdlets were used to access the registry and create the appropriate entities required to disable Chrome's auto update feature:
  • Test-Path: tests is a registry key exists
  • New-Item: creates a registry key
  • Set-ItemProperty: update a registry value if the value already exists or creates a registry value of the value does not exist

No comments :

Post a Comment