From 20cefe10b6044306cf940179dce2955edcb64a32 Mon Sep 17 00:00:00 2001 From: David Yoder Date: Mon, 22 Apr 2024 11:31:28 -0400 Subject: [PATCH] initial commit --- Fix-RebootIntoSafeMode.ps1 | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Fix-RebootIntoSafeMode.ps1 diff --git a/Fix-RebootIntoSafeMode.ps1 b/Fix-RebootIntoSafeMode.ps1 new file mode 100644 index 0000000..23b32b1 --- /dev/null +++ b/Fix-RebootIntoSafeMode.ps1 @@ -0,0 +1,31 @@ +# List of services to configure +$Services = @( + "Syncro" + "SyncroLive" + "SyncroOvermind" + "SplashtopRemoteService" +) + +# Configure necessary services to restart in Safe Mode with Networking +$Services | ForEach-Object { + If ( Get-Service $_ -ErrorAction SilentlyContinue ) { + Write-Output "Configuring ${_} service to start in Safe Mode with Networking" + Try { New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Control\SafeBoot\Network\${_}" -Force -ErrorAction SilentlyContinue } + Catch { Write-Error "ERROR: could not configure ${_} service to start in Safe Mode with Networking" ; Return } + } +} + +# Configure system to reboot into Normal Mode at next reboot +Write-Output "Configuring system to reboot into Normal Mode at next reboot" +Try { [Microsoft.Win32.Registry]::SetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Runonce",'*RestartNormalMode','%SystemRoot%\System32\bcdedit.exe /deletevalue {default} safeboot',[Microsoft.Win32.RegistryValueKind]::String) } +Catch { Write-Error "ERROR: could not configure reboot into normal mode" ; Return } + +# Configure reboot into Safe Mode with Networking +Write-Output "Configuring system to reboot into Safe Mode with Networking" +Try { "%SystemRoot%\System32\bcdedit.exe" /set {default} safeboot network } +Catch { Write-Error "ERROR: could not configure reboot into safe mode with networking" ; Return } + +# Reboot into Safe Mode with Networking +Write-Output "Rebooting into Safe Mode with Networking" +Try { Start-Sleep -Seconds 5 ; Restart-Computer -Force -ErrorAction Stop} +Catch { Write-Error "ERROR: could not reboot into safe mode with networking" ; Return } \ No newline at end of file