powershell Google Firefox

$firefox = @{

  DisplayName = "Mozilla Firefox";
  filename = "Firefox Setup 68.0b7.msi"
  Url = "\\10.63.32.243\Share\Browsers\Firefox Setup 68.0b7.msi"
  }
  
  $Chrome = @{
  
  DisplayName = "Google Chrome";
  filename = "GoogleChromeStandaloneEnterprise64.msi"
  Url = "\\10.63.32.243\Share\Browsers\GoogleChromeStandaloneEnterprise64.msi"
  }

  function Test-Installation {
    Param([Parameter(Position = 0, Mandatory = $true)] [String] $DisplayName)

    $key1 = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*"
    $key2 = "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"
    $installed1 = Get-ItemProperty -Path $key1 | Select-Object DisplayName | Where-Object { $_.DisplayName -and $_.DisplayName.Contains($DisplayName) }
    $installed2 = Get-ItemProperty -Path $key2 | Select-Object DisplayName | Where-Object { $_.DisplayName -and $_.DisplayName.Contains($DisplayName) }
    if (($null -eq $installed1) -and ($null -eq $installed2)) { return $false } else { return $true }
}

Write-Host "Step 1. Install firefox" -ForegroundColor Cyan
if (Test-Installation -DisplayName $firefox.DisplayName) {
    Write-Host "firefox has been installed!" -ForegroundColor Green
} else {
    Start-BitsTransfer $firefox.url "$env:temp\$filename"
    $destination = "$env:temp"
    msiexec /i "$destination\Firefox Setup 68.0b7.msi" /norestart INSTALLSERVICE=1 /QUIET |out-null
    Write-Host "firefox installed success!"
    }

Write-Host "Step 2. Install chrome" -ForegroundColor Cyan
if (Test-Installation -DisplayName $chrome.DisplayName) {
    Write-Host "chrome has been installed!" -ForegroundColor Green
} else {
    Start-BitsTransfer $chrome.url "$env:temp\$filename"
    $destination = "$env:temp"
    
    msiexec /i "$destination\GoogleChromeStandaloneEnterprise64.msi" /norestart INSTALLSERVICE=1 /QUIET |out-null
    Write-Host "chrome installed success!"
    }

 

posted @ 2019-06-13 14:24  市丸银  阅读(237)  评论(0编辑  收藏  举报