major change to override Write-Error func

This commit is contained in:
2023-10-05 13:17:18 -04:00
parent bbb4884818
commit 5f4b4565de
42 changed files with 114 additions and 114 deletions
+5 -5
View File
@@ -7,17 +7,17 @@ $TEMPDIR = '{0}eset-protect-deployment' -f (Get-TempPath)
If ( Test-Path $TEMPDIR ) {
Write-Output """${TEMPDIR}"" already exists and will be deleted"
Try { Remove-Item -Path $TEMPDIR -Recurse -Force -ErrorAction SilentlyContinue }
Catch { LogErr $_.Exception.Message }
Catch { Write-Error $_.Exception.Message }
}
# Create $TEMPDIR
Write-Output "Creating: ${TEMPDIR}"
Try { New-Item -Path $TEMPDIR -ItemType Directory -Force -ErrorAction Stop }
Catch { LogErr $_.Exception.Message ; Exit }
Catch { Write-Error $_.Exception.Message ; Exit }
# 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." ; LogErr $_.Exception.Message ; Exit }
Catch { Write-Output "Cannot write configuration file! This script will exit." ; Write-Error $_.Exception.Message ; Exit }
# Get bitness of endpoint and set $AGENTNAME
If ( Is64bit ) { $AGENTNAME = "agent_x64.msi" } Else { $AGENTNAME = "agent_x86.msi" }
@@ -31,9 +31,9 @@ Download-File -URL $URL -File $INSTALLER
# Install the app
Write-Output "Installing ESET Management Agent from ""${INSTALLER}"""
Try { Start-Process "msiexec.exe" -ArgumentList "/i ${INSTALLER} /qn /norestart /log installer.log" -Wait }
Catch { LogErr $_.Exception.Message }
Catch { Write-Error $_.Exception.Message }
# Delete the installer
Write-Output "Deleting temp directory and its contents"
Try { Remove-Item -Path $TEMPDIR -Recurse -Force -ErrorAction SilentlyContinue }
Catch { LogErr $_.Exception.Message }
Catch { Write-Error $_.Exception.Message }