correctly detect safe mode with networking

update ESET Uninstaller download link
This commit is contained in:
2024-04-23 22:55:57 -04:00
parent 4cec14c893
commit 6941d7aad4
+5 -5
View File
@@ -1,6 +1,5 @@
# Are we running in Safe Mode with Networking?
Try { If ( ($Env:SAFEBOOT_OPTIONS).ToUpper() -eq "NETWORK" ) { $InSafeNetMode = $true } Else { $InSafeNetMode = $false } }
Catch { $InSafeNetMode = $false }
If ( (Get-CimInstance -ClassName Win32_ComputerSystem).BootupState.ToLower() -eq "fail-safe with network boot" ) { $InSafeNetMode = $true } Else { $InSafeNetMode = $false }
Switch ( $InSafeNetMode ) {
@@ -8,7 +7,7 @@ Switch ( $InSafeNetMode ) {
$true {
# Download the ESET Uninstaller
Write-Output "Downloading ESET Uninstaller to: ${ESETUninstaller}"
$ESETUninstallerURL = "https://download.eset.com/computer/uninstaller/esetuninstaller.exe"
$ESETUninstallerURL = "https://download.eset.com/com/eset/tools/installers/eset_apps_remover/latest/esetuninstaller.exe"
Download-File -URL $ESETUninstallerURL -File $ESETUninstaller
If ( !(Test-Path $ESETUninstaller) ) { Write-Error "ERROR: ESET Uninstaller could not be downloaded, this script will exit" ; Return }
@@ -50,8 +49,9 @@ Switch ( $InSafeNetMode ) {
# Schedule this script to run in Safe Mode
$key = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Runonce'
Try { New-ItemProperty -Path $key -Name '*Remove-AllESETProducts' -Value 'powershell.exe -ExecutionPolicy Bypass -Command {. $([Scriptblock]::Create((New-Object Net.WebClient).DownloadString("https://dev.emberkom.com/emberkom/management-scripts/raw/branch/master/Tools.ps1"))) ; Run-Script -LivePSScript Remove-AllESETProducts}' -PropertyType String -Force }
Catch { Write-Error "ERROR: could not configure reboot into normal mode" ; Return }
$encodedCommand = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes('. $([Scriptblock]::Create((New-Object Net.WebClient).DownloadString("https://dev.emberkom.com/emberkom/management-scripts/raw/branch/master/Tools.ps1"))) ; Run-Script -LivePSScript Remove-AllESETProducts'))
Try { New-ItemProperty -Path $key -Name '*Remove-AllESETProducts' -Value "powershell.exe -ExecutionPolicy Bypass -EncodedCommand ${encodedCommand}" -PropertyType String -Force }
Catch { Write-Error "ERROR: could not configure Remove-AllESETProducts script to run at next boot" ; Return }
# Restart the computer into Safe Mode with Networking
Run-Script -LivePSScript Fix-RebootIntoSafeMode