msi通过powershell安装、卸载

function install_msi($url) 
{
  $telemetry = @{
    DisplayName = "Telemetry Service";
    filename = "TelemetryServiceInstaller_x64.msi"
    Url = $url
  }
  Write-Host $telemetry.Url
  Write-Host 'Install TelemetryService'
  Start-BitsTransfer $telemetry.Url "$env:temp\$filename"
  $destination = "$env:temp"
  msiexec /i "$destination\TelemetryServiceInstaller_x64.msi" /norestart INSTALLSERVICE=1 /QUIET |out-null
  Write-Host "TelemetryService installed success!"
  
}
$url = "\\10.63.32.243\Share\Telemetry\Master Build\113\Release\x64\TelemetryServiceInstaller_x64.msi"
install_msi $url
function unstall_msi($url) 
{
  $telemetry = @{
    DisplayName = "Telemetry Service";
    filename = "TelemetryServiceInstaller_x64.msi"
    Url = $url
  }
  Write-Host $telemetry.Url
  Write-Host 'Unstall TelemetryService'
  Start-BitsTransfer $telemetry.Url "$env:temp\$filename"
  $destination = "$env:temp"
  msiexec /uninstall "$destination\TelemetryServiceInstaller_x64.msi" /norestart INSTALLSERVICE=1 /QUIET |out-null
  Write-Host "TelemetryService unstalled success!"
  
}
$url = "\\10.63.32.243\Share\Telemetry\Master Build\113\Release\x64\TelemetryServiceInstaller_x64.msi"
unstall_msi $url

 

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