Configuration Manager 2012 Compliance Baseline to Disable Mozilla Firefox Automatic Updates

Posted: August 12, 2014 in System Center Configuration Manager 2012
Tags: , ,

In this post I’m not going to explain how to create a Compliance Item and Baseline for that you can review this post; Configuration Manager 2012 Compliance Baseline to Disable Adobe Air Automatic Updates.

Below you will find scripts for Discovery and Remediation of Mozilla Firefox automatic updates.

<#
  This script will check if automatic updates is disabled and return a Compliant/Non-Compliant string.
  
  Created:     04.08.2014
  Version:     1.0
  Author:      Odd-Magne Kristoffersen
  Homepage:    https://sccmguru.wordpress.com/
    
  References:
  - Disable Automatic Updates
    https://support.mozilla.org/en-US/questions/944982
  - Locking preferences
    http://kb.mozillazine.org/Locking_preferences
#>

$OSArchitecture = Get-WmiObject -Class Win32_OperatingSystem | Select-Object OSArchitecture

If($OSArchitecture.OSArchitecture -ne "32-bit")
    {
    $UpdateCheck1 = Select-String 'C:\Program Files (x86)\Mozilla Firefox\mozilla.cfg' -pattern "app.update.auto" | Select-Object Line
    $UpdateCheck2 = Select-String 'C:\Program Files (x86)\Mozilla Firefox\mozilla.cfg' -pattern "app.update.enabled" | Select-Object Line
    $UpdateCheck3 = Select-String 'C:\Program Files (x86)\Mozilla Firefox\defaults\pref\local-settings.js' -pattern "general.config.obscure_value" | Select-Object Line
    $UpdateCheck4 = Select-String 'C:\Program Files (x86)\Mozilla Firefox\defaults\pref\local-settings.js' -pattern "general.config.filename" | Select-Object Line

        if(($UpdateCheck1.Line -eq 'lockPref("app.update.auto", false);')  -and ($UpdateCheck2.Line -eq 'lockPref("app.update.enabled", false);')  -and ($UpdateCheck3.Line -eq 'pref("general.config.obscure_value", 0);')  -and ($UpdateCheck4.Line -eq 'pref("general.config.filename", "mozilla.cfg");'))
    {Write-Host 'Compliant'}
    else 
    {Write-Host 'Non-Compliant'}
    }
else
    {
    $UpdateCheck1 = Select-String 'C:\Program Files\Mozilla Firefox\mozilla.cfg' -pattern "app.update.auto" | Select-Object Line
    $UpdateCheck2 = Select-String 'C:\Program Files\Mozilla Firefox\mozilla.cfg' -pattern "app.update.enabled" | Select-Object Line
    $UpdateCheck3 = Select-String 'C:\Program Files\Mozilla Firefox\defaults\pref\local-settings.js' -pattern "general.config.obscure_value" | Select-Object Line
    $UpdateCheck4 = Select-String 'C:\Program Files\Mozilla Firefox\defaults\pref\local-settings.js' -pattern "general.config.filename" | Select-Object Line

        if(($UpdateCheck1.Line -eq 'lockPref("app.update.auto", false);')  -and ($UpdateCheck2.Line -eq 'lockPref("app.update.enabled", false);')  -and ($UpdateCheck3.Line -eq 'pref("general.config.obscure_value", 0);')  -and ($UpdateCheck4.Line -eq 'pref("general.config.filename", "mozilla.cfg");'))
    {Write-Host 'Compliant'}
    else 
    {Write-Host 'Non-Compliant'}
    }
<#
  This script will disable automatic updates if it is enabled.
  
  Created:     04.08.2014
  Version:     1.0
  Author:      Odd-Magne Kristoffersen
  Homepage:    https://sccmguru.wordpress.com/
    
  References:
  - Disable Automatic Updates
    https://support.mozilla.org/en-US/questions/944982
  - Locking preferences
    http://kb.mozillazine.org/Locking_preferences
#>

$OSArchitecture = Get-WmiObject -Class Win32_OperatingSystem | Select-Object OSArchitecture

If($OSArchitecture.OSArchitecture -ne "32-bit")
{
    $CFGPath = "C:\Program Files (x86)\Mozilla Firefox\mozilla.cfg"
    $CFGExists = Test-Path -Path $CFGPath
         if($CFGExists -eq $True) 
            {
            $a = Get-Content $CFGPath
            $b = 'lockPref("app.update.auto", false);'
            $c = 'lockPref("app.update.enabled", false);'
            Set-Content $CFGPath -Value $a, $b, $c
            }
            else
            {
            $b = 'lockPref("app.update.auto", false);'
            $c = 'lockPref("app.update.enabled", false);'
            Add-Content $CFGPath -Value $b, $c
            }

    $JSPath = "C:\Program Files (x86)\Mozilla Firefox\defaults\pref\local-settings.js"
    $JSExists = Test-Path -Path $JSPath
         if($JSExists -eq $True) 
            {
            $a = Get-Content $JSPath
            $b = 'pref("general.config.obscure_value", 0);'
            $c = 'pref("general.config.filename", "mozilla.cfg");'
            Set-Content $JSPath -Value $a, $b, $c
            }
            else
            {
            $b = 'pref("general.config.obscure_value", 0);'
            $c = 'pref("general.config.filename", "mozilla.cfg");'
            Add-Content $JSPath -Value $b, $c
            }

}
else
{
    $CFGPath = "C:\Program Files\Mozilla Firefox\mozilla.cfg"
    $CFGExists = Test-Path -Path $CFGPath
         if($CFGExists -eq $True) 
            {
            $a = Get-Content $CFGPath
            $b = 'lockPref("app.update.auto", false);'
            $c = 'lockPref("app.update.enabled", false);'
            Set-Content $CFGPath -Value $a, $b, $c
            }
            else
            {
            $b = 'lockPref("app.update.auto", false);'
            $c = 'lockPref("app.update.enabled", false);'
            Add-Content $CFGPath -Value $b, $c
            }

    $JSPath = "C:\Program Files\Mozilla Firefox\defaults\pref\local-settings.js"
    $JSExists = Test-Path -Path $JSPath
         if($JSExists -eq $True) 
            {
            $a = Get-Content $JSPath
            $b = 'pref("general.config.obscure_value", 0);'
            $c = 'pref("general.config.filename", "mozilla.cfg");'
            Set-Content $JSPath -Value $a, $b, $c
            }
            else
            {
            $b = 'pref("general.config.obscure_value", 0);'
            $c = 'pref("general.config.filename", "mozilla.cfg");'
            Add-Content $JSPath -Value $b, $c
            }
}

You can also download the scripts here: Compliance Settings Scripts

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s