Advertisement
pedronrivera

Install FireFox with PowerShell

Mar 15th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Install FireFox with PowerShell
  2. # Silent Install Firefox
  3. # Download URL: https://www.mozilla.org/en-US/firefox/all/
  4. # Path for the workdir
  5. $workdir = "c:\installer\"
  6. # Check if work directory exists if not create it
  7. If (Test-Path -Path $workdir -PathType Container)
  8. { Write-Host "$workdir already exists" -ForegroundColor Red}
  9. ELSE
  10. { New-Item -Path $workdir  -ItemType directory }
  11. # Download the installer
  12. $source = "https://download.mozilla.org/?product=firefox-51.0.1-SSL&os=win64&lang=en-US"
  13. $destination = "$workdir\firefox.exe"
  14. # Check if Invoke-Webrequest exists otherwise execute WebClient
  15. if (Get-Command 'Invoke-Webrequest')
  16. {
  17.      Invoke-WebRequest $source -OutFile $destination
  18. }
  19. else
  20. {
  21.     $WebClient = New-Object System.Net.WebClient
  22.     $webclient.DownloadFile($source, $destination)
  23. }
  24. # Start the installation
  25. Start-Process -FilePath "$workdir\firefox.exe" -ArgumentList "/S"
  26. # Wait XX Seconds for the installation to finish
  27. Start-Sleep -s 35
  28. # Remove the installer
  29. rm -Force $workdir\firefox*
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement