reinstall if errors are found in status log
This commit is contained in:
@@ -1,9 +1,15 @@
|
||||
# NOTE: The $CONFIG variable must be set by the calling script
|
||||
|
||||
# Exit this script if agent is already installed
|
||||
# Check whether agent is already installed
|
||||
If ( Test-Path "${Env:ProgramFiles}\ESET\RemoteAdministrator\Agent\ERAAgent.exe" ) {
|
||||
Microsoft.Powershell.Utility\Write-Output "ESET agent is already installed. This script will now exit."
|
||||
Return
|
||||
|
||||
# End the script if no errors are found in the status log
|
||||
If ( !(Select-String -Path "${Env:ProgramData}\ESET\RemoteAdministrator\Agent\EraAgentApplicationData\Logs\status.html" -CaseSensitive -Pattern 'Error:' -Quiet) ) {
|
||||
Microsoft.Powershell.Utility\Write-Output "ESET agent is already installed and no errors were found. This script will now exit."
|
||||
Return
|
||||
}
|
||||
|
||||
Write-Output "ESET agent is already installed, but errors were found in the status log. This script will continue and attempt to reinstall the agent."
|
||||
}
|
||||
|
||||
# Set path to temp directory
|
||||
@@ -19,11 +25,11 @@ If ( Test-Path $TEMPDIR ) {
|
||||
# Create $TEMPDIR
|
||||
Write-Output "Creating: ${TEMPDIR}"
|
||||
Try { New-Item -Path $TEMPDIR -ItemType Directory -Force -ErrorAction Stop }
|
||||
Catch { Write-Error $_.Exception.Message ; Exit }
|
||||
Catch { Write-Error $_.Exception.Message ; Return }
|
||||
|
||||
# Write $CONFIG to install_config.ini
|
||||
Try { $CONFIG | WriteToFile_UTF8NoBOM -FilePath "${TEMPDIR}\install_config.ini" }
|
||||
Catch { Write-Output "Cannot write configuration file! This script will exit." ; Write-Error $_.Exception.Message ; Exit }
|
||||
Catch { Write-Output "Cannot write configuration file! This script will exit." ; Write-Error $_.Exception.Message ; Return }
|
||||
|
||||
# Get bitness of endpoint and set $AGENTNAME
|
||||
If ( Is64bit ) { $AGENTNAME = "agent_x64.msi" } Else { $AGENTNAME = "agent_x86.msi" }
|
||||
|
||||
Reference in New Issue
Block a user