How Do You Install Firefox on a Windows Server with PowerShell?

Problem scenario
You want to install Firefox on a Windows server without using the traditional GUI method. What should you do?

1. Open PowerShell ISE as Administrator (right click it, go to More -> Run as Administrator).
2. Run this script (e.g., firefox.ps1):

# This script was mostly taken from

# changed the version number of Firefox and added some comments
# Silent Install Firefox 

# Download URL:

# Path for the workdir
$workdir = "c:\installer\"

# Check if work directory exists if not create it

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

# Download the installer

$source = ""
$destination = "$workdir\firefox.exe"

# Check if Invoke-Webrequest exists otherwise execute WebClient

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

# Start the installation

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

# Wait XX Seconds for the installation to finish

Start-Sleep -s 35

# Remove the installer

rm -Force $workdir\firefox*

# write-host should be changed to write-verbose  # we have not tried it yet with these directions

Leave a comment

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