Created
March 28, 2020 19:40
-
-
Save scotgabriel/3f95eeec53eb43f0e3acf0196165ceb9 to your computer and use it in GitHub Desktop.
Firefox install script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Silently Install Firefox | |
# 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} | |
ELSE | |
{ New-Item -Path $workdir -ItemType directory } | |
# Download the installer | |
$source = "https://download.mozilla.org/?product=firefox-latest&os=win64&lang=en-US" | |
$destination = "$workdir\firefox.exe" | |
# Check if Invoke-Webrequest exists otherwise execute WebClient | |
if (Get-Command 'Invoke-Webrequest') | |
{ | |
Invoke-WebRequest $source -OutFile $destination | |
} | |
else | |
{ | |
$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 120 | |
# Remove the installer | |
rm -Force $workdir\firefox* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment