removed code to reboot into safe mode
minor changes to messages
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
# Are we running in Safe Mode with Networking?
|
||||
If ( (Get-CimInstance -ClassName Win32_ComputerSystem).BootupState.ToLower() -eq "fail-safe with network boot" ) { $InSafeNetMode = $true } Else { $InSafeNetMode = $false }
|
||||
# Make sure we're booted into Safe Mode with Networking
|
||||
If ( !((Get-CimInstance -ClassName Win32_ComputerSystem).BootupState.ToLower() -eq "fail-safe with network boot") ) {
|
||||
Write-Output "Cannot run script because the system is not currently booted into Safe Mode with Networking"
|
||||
Return
|
||||
}
|
||||
|
||||
Switch ( $InSafeNetMode ) {
|
||||
|
||||
# We're in Safe Mode
|
||||
$true {
|
||||
# Download the ESET Uninstaller
|
||||
Write-Output "Downloading ESET Uninstaller to: ${ESETUninstaller}"
|
||||
$ESETUninstallerURL = "https://download.eset.com/com/eset/tools/installers/eset_apps_remover/latest/esetuninstaller.exe"
|
||||
@@ -35,28 +34,14 @@ Switch ( $InSafeNetMode ) {
|
||||
$params = "/deletevalue {default} safeboot".Split(" ")
|
||||
Try { & "${command}" $params }
|
||||
Catch {
|
||||
If ( $_.Exception.Message -match "Element not found" ) { Write-Output "Safe mode is already disabled" }
|
||||
If ( $_.Exception.Message -match "Element not found" ) { Write-Output " - Safe mode has already been disabled" }
|
||||
Else { Write-Error "ERROR: could not disable safe mode, manual intervention may be required" }
|
||||
}
|
||||
|
||||
# Reboot into normal mode
|
||||
Write-Output "Rebooting into normal mode"
|
||||
& "${Env:SystemRoot}\System32\shutdown.exe" -r -f -t 5
|
||||
}
|
||||
|
||||
# We're not in Safe Mode
|
||||
$false {
|
||||
|
||||
# Schedule this script to run in Safe Mode
|
||||
$key = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Runonce'
|
||||
$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
|
||||
}
|
||||
}
|
||||
& "${Env:SystemRoot}\System32\shutdown.exe" -r -f -t 60 -c "Operation complete. The computer will restart in 60 seconds."
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user