Installing MSI Installers Silently with ScreenConnect (like Admin By Request)

We found this code when we migrated our ScreenConnect instance to the cloud. This was the "migration" script which we modified for use with msiexec. 

Update the last line with parameters for your organization.

#!ps
#timeout=3000000
#maxlength=1000000
function downloadFile($url)
{
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$uri = New-Object "System.Uri" "$url"
$targetFile = "${env:TEMP}\installer.msi"
$request = [System.Net.HttpWebRequest]::Create($uri)
$request.set_Timeout(1200000)
$response = $request.GetResponse()
$responseStream = $response.GetResponseStream()
$targetStream = New-Object -TypeName System.IO.FileStream -ArgumentList $targetFile, Create
$buffer = new-object byte[] 10KB
$count = $responseStream.Read($buffer,0,$buffer.length)
$downloadedBytes = $count
while ($count -gt 0)
{
$targetStream.Write($buffer, 0, $count)
$count = $responseStream.Read($buffer,0,$buffer.length)
$downloadedBytes = $downloadedBytes + $count
}
$targetStream.Flush()
$targetStream.Close()
$targetStream.Dispose()
$responseStream.Dispose()
}
downloadFile "https://myhost.host.com/your_installer.msi"; Start-Process "msiexec.exe" -ArgumentList "/I ${env:TEMP}\installer.msi /QN"  -NoNewWindow -Wait -PassThru