diff --git a/Install-ESETManagementAgent.ps1 b/Install-ESETManagementAgent.ps1 index 932397c..503a2d3 100644 --- a/Install-ESETManagementAgent.ps1 +++ b/Install-ESETManagementAgent.ps1 @@ -6,6 +6,13 @@ LogMsg "Creating: ${TEMPDIR}" Try { New-Item -Path $TEMPDIR -ItemType Directory -Force -ErrorAction Stop } Catch { LogErr $_.Exception.Message ; Exit } +# Recursively delete $TEMPDIR if it already exists +If ( Test-Path $TEMPDIR ) { + LogMsg """${TEMPDIR}"" already exists and will be deleted" + Try { Remove-Item -Path $TEMPDIR -Recurse -Force } + Catch { LogErr $_.Exception.Message } +} + # Write $CONFIG to install_config.ini Try { $CONFIG | Out-File -FilePath "${TEMPDIR}\install_config.ini" -Force -ErrorAction Stop } Catch { LogMsg "Cannot write configuration file! This script will exit." ; LogErr $_.Exception.Message ; Exit }