How to install Mozilla Firefox using Powershell

Estimated reading time: 1 min

Introduction

In this article, you will learn how to install Mozilla Firefox using Powershell. Internet explorer is the preinstalled default browser provided by Microsoft. You can follow these easy steps to install Mozilla Firefox via Powershell. 

Prerequisites

  • Windows OS (10 or server)
  • Powershell v4.0 or higher

Step 1: Open Powershell

Type in the search bar “Powershell” then press on the mouse right-click and select “Run as administrator” then click on “Yes”.

Powershell run as admin

Win powershell

Step 2: Powershell code

Copy the following code and paste it in Powershell then press Enter.

$workdir = "c:\installer\"

If (Test-Path -Path $workdir -PathType Container)
{ Write-Host "$workdir already exists" -ForegroundColor Red}
ELSE
{ New-Item -Path $workdir  -ItemType directory }

$source = "https://download.mozilla.org/?product=firefox-latest&os=win64&lang=en-US"
$destination = "$workdir\firefox.exe"

if (Get-Command 'Invoke-Webrequest')
{
     Invoke-WebRequest $source -OutFile $destination
}
else
{
    $WebClient = New-Object System.Net.WebClient
    $webclient.DownloadFile($source, $destination)
}

Start-Process -FilePath "$workdir\firefox.exe" -ArgumentList "/S"

Start-Sleep -s 35

rm -Force $workdir/firefox*

Powershell code paste

Wait until the process is finished.

Powershell code finished

Conclusion

Congratulations, you have successfully installed Mozilla Firefox using Powershell

Was this article helpful?
Dislike 10
Views: 29403

Reader Interactions

Leave a Reply

Your email address will not be published. Required fields are marked *