diff --git a/scripts/windows/InstallScript.ps1 b/scripts/windows/InstallScript.ps1 index 966d125..df8e5b5 100644 --- a/scripts/windows/InstallScript.ps1 +++ b/scripts/windows/InstallScript.ps1 @@ -2,8 +2,8 @@ $Token = ""; $Password = ""; $addRemove = 0; # default is 0 -$originalProtocol = [System.Net.ServicePointManager]::SecurityProtocol -[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::'SystemDefault' +# Set TLS 1.2 in a manner compatible with older .Net installations. +[Net.ServicePointManager]::SecurityProtocol = [Enum]::ToObject([Net.SecurityProtocolType], 3072) # Determine whether or not the agent is already installed $InstalledSoftware = Get-ChildItem "HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall" @@ -12,7 +12,7 @@ foreach($obj in $InstalledSoftware) if ($obj.GetValue('DisplayName') -match "Archon") { Write-Host "Zorus Deployment Agent is already installed. Exiting." - Exit + Exit 0 } } @@ -20,7 +20,7 @@ if ([string]::IsNullOrEmpty($Token)) { # Token must be set Write-Host "Deployment token not provided. Exiting." - Exit + Exit 1 } $source = "https://static.zorustech.com/downloads/ZorusInstaller.exe" @@ -35,22 +35,22 @@ try catch { Write-Host "Failed to download installer. Exiting." - Exit + Exit 1 } if ([string]::IsNullOrEmpty($Password)) { Write-Host "Installing Zorus Deployment Agent..." - Start-Process -FilePath $destination -ArgumentList "/qn", "ARCHON_TOKEN=$Token", "HIDE_ADD_REMOVE=$addRemove" -Wait + $Process = Start-Process -FilePath $destination -ArgumentList "/qn", "ARCHON_TOKEN=$Token", "HIDE_ADD_REMOVE=$addRemove" -Wait -NoNewWindow -PassThru } else { Write-Host "Installing Zorus Deployment Agent with password..." - Start-Process -FilePath $destination -ArgumentList "/qn", "ARCHON_TOKEN=$Token", "HIDE_ADD_REMOVE=$addRemove", "UNINSTALL_PASSWORD=$Password" -Wait + $Process = Start-Process -FilePath $destination -ArgumentList "/qn", "ARCHON_TOKEN=$Token", "HIDE_ADD_REMOVE=$addRemove", "UNINSTALL_PASSWORD=$Password" -Wait -NoNewWindow -PassThru } Write-Host "Removing temporary files..." Remove-Item -recurse $destination Write-Host "Installation complete." -[System.Net.ServicePointManager]::SecurityProtocol = $originalProtocol +Exit $Process.ExitCode \ No newline at end of file diff --git a/scripts/windows/UninstallScript.ps1 b/scripts/windows/UninstallScript.ps1 index 9f6c7ec..5dbe289 100644 --- a/scripts/windows/UninstallScript.ps1 +++ b/scripts/windows/UninstallScript.ps1 @@ -1,7 +1,7 @@ $Password = "" -$originalProtocol = [System.Net.ServicePointManager]::SecurityProtocol -[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::'SystemDefault' +# Set TLS 1.2 in a manner compatible with older .Net installations. +[Net.ServicePointManager]::SecurityProtocol = [Enum]::ToObject([Net.SecurityProtocolType], 3072) $source = "https://static.zorustech.com/downloads/ZorusAgentRemovalTool.exe"; $destination = "$env:TEMP\ZorusAgentRemovalTool.exe"; @@ -15,22 +15,22 @@ try catch { Write-Host "Failed to download removal tool. Exiting." - Exit + Exit 1 } if ([string]::IsNullOrEmpty($Password)) { Write-Host "Uninstalling Zorus Deployment Agent..." - Start-Process -FilePath $destination -ArgumentList "-s" -Wait + $Process = Start-Process -FilePath $destination -ArgumentList "-s" -Wait -NoNewWindow -PassThru } else { Write-Host "Uninstalling Zorus Deployment Agent with password..." - Start-Process -FilePath $destination -ArgumentList "-s", "-p $Password" -Wait + $Process = Start-Process -FilePath $destination -ArgumentList "-s", "-p $Password" -Wait -NoNewWindow -PassThru } Write-Host "Removing temporary files..." Remove-Item -recurse $destination Write-Host "Removal complete." -[System.Net.ServicePointManager]::SecurityProtocol = $originalProtocol +Exit $Process.ExitCode \ No newline at end of file diff --git a/scripts/windows/UpdateScript.ps1 b/scripts/windows/UpdateScript.ps1 index 3552b1f..9dc821f 100644 --- a/scripts/windows/UpdateScript.ps1 +++ b/scripts/windows/UpdateScript.ps1 @@ -2,8 +2,8 @@ # Please do NOT use this for fresh installs as it doesn't allow input for # deployment tokens and other necessary first time install variables. -$originalProtocol = [System.Net.ServicePointManager]::SecurityProtocol -[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::'SystemDefault' +# Set TLS 1.2 in a manner compatible with older .Net installations. +[Net.ServicePointManager]::SecurityProtocol = [Enum]::ToObject([Net.SecurityProtocolType], 3072) $source = "https://static.zorustech.com/downloads/ZorusInstaller.exe" $destination = "$env:TEMP\ZorusInstaller.exe" @@ -17,14 +17,14 @@ try catch { Write-Host "Failed to download update. Exiting." - Exit + Exit 1 } Write-Host "Updating Zorus Deployment Agent..." -Start-Process -FilePath $destination -ArgumentList @('/qn ALLUSERS="1" AUTO_UPGRADE="1" /L*V "C:\Windows\Temp\ZorusInstaller.log"') -Wait +$Process = Start-Process -FilePath $destination -ArgumentList @('/qn ALLUSERS="1" AUTO_UPGRADE="1" /L*V "C:\Windows\Temp\ZorusInstaller.log"') -Wait -NoNewWindow -PassThru Write-Host "Removing temporary files..." Remove-Item -recurse $destination Write-Host "Update complete." -[System.Net.ServicePointManager]::SecurityProtocol = $originalProtocol +Exit $Process.ExitCode \ No newline at end of file