correctly detect safe mode with networking
update ESET Uninstaller download link
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
# Are we running in Safe Mode with Networking?
|
# Are we running in Safe Mode with Networking?
|
||||||
Try { If ( ($Env:SAFEBOOT_OPTIONS).ToUpper() -eq "NETWORK" ) { $InSafeNetMode = $true } Else { $InSafeNetMode = $false } }
|
If ( (Get-CimInstance -ClassName Win32_ComputerSystem).BootupState.ToLower() -eq "fail-safe with network boot" ) { $InSafeNetMode = $true } Else { $InSafeNetMode = $false }
|
||||||
Catch { $InSafeNetMode = $false }
|
|
||||||
|
|
||||||
Switch ( $InSafeNetMode ) {
|
Switch ( $InSafeNetMode ) {
|
||||||
|
|
||||||
@@ -8,7 +7,7 @@ Switch ( $InSafeNetMode ) {
|
|||||||
$true {
|
$true {
|
||||||
# Download the ESET Uninstaller
|
# Download the ESET Uninstaller
|
||||||
Write-Output "Downloading ESET Uninstaller to: ${ESETUninstaller}"
|
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
|
Download-File -URL $ESETUninstallerURL -File $ESETUninstaller
|
||||||
If ( !(Test-Path $ESETUninstaller) ) { Write-Error "ERROR: ESET Uninstaller could not be downloaded, this script will exit" ; Return }
|
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
|
# Schedule this script to run in Safe Mode
|
||||||
$key = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Runonce'
|
$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 }
|
$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'))
|
||||||
Catch { Write-Error "ERROR: could not configure reboot into normal mode" ; Return }
|
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
|
# Restart the computer into Safe Mode with Networking
|
||||||
Run-Script -LivePSScript Fix-RebootIntoSafeMode
|
Run-Script -LivePSScript Fix-RebootIntoSafeMode
|
||||||
|
|||||||
Reference in New Issue
Block a user