Merge pull request #407 from bradhawkins85/patch-15

Update installer.ps1
This commit is contained in:
Dan 2021-04-16 22:05:14 -07:00 committed by GitHub
commit eacce4578a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 31 additions and 19 deletions

View File

@ -9,6 +9,7 @@ $rdp = rdpchange
$ping = pingchange $ping = pingchange
$auth = '"tokenchange"' $auth = '"tokenchange"'
$downloadlink = 'downloadchange' $downloadlink = 'downloadchange'
$apilink = $downloadlink.split('/')
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
@ -47,24 +48,35 @@ If (Get-Service $serviceName -ErrorAction SilentlyContinue) {
# pass # pass
} }
Try $X = 0
{ do {
Invoke-WebRequest -Uri $downloadlink -OutFile $OutPath\$output Write-Output "Waiting for network"
Start-Process -FilePath $OutPath\$output -ArgumentList ('/VERYSILENT /SUPPRESSMSGBOXES') -Wait Start-Sleep -s 5
write-host ('Extracting...') $X += 1
Start-Sleep -s 5 } until(($connectreult = Test-NetConnection $apilink[2] -Port 443 | ? { $_.TcpTestSucceeded }) -or $X -eq 3)
Start-Process -FilePath "C:\Program Files\TacticalAgent\tacticalrmm.exe" -ArgumentList $installArgs -Wait
exit 0 if ($connectreult.TcpTestSucceeded -eq $true){
} Try
Catch {
{ Invoke-WebRequest -Uri $downloadlink -OutFile $OutPath\$output
$ErrorMessage = $_.Exception.Message Start-Process -FilePath $OutPath\$output -ArgumentList ('/VERYSILENT /SUPPRESSMSGBOXES') -Wait
$FailedItem = $_.Exception.ItemName write-host ('Extracting...')
Write-Error -Message "$ErrorMessage $FailedItem" Start-Sleep -s 5
exit 1 Start-Process -FilePath "C:\Program Files\TacticalAgent\tacticalrmm.exe" -ArgumentList $installArgs -Wait
} exit 0
Finally }
{ Catch
Remove-Item -Path $OutPath\$output {
$ErrorMessage = $_.Exception.Message
$FailedItem = $_.Exception.ItemName
Write-Error -Message "$ErrorMessage $FailedItem"
exit 1
}
Finally
{
Remove-Item -Path $OutPath\$output
}
} else {
Write-Output "Unable to connect to server"
} }
} }