From 391a19686fc0013f365ac25598edf8e60f4abba5 Mon Sep 17 00:00:00 2001 From: Mathieu Moran Date: Thu, 13 Oct 2022 21:47:09 -0400 Subject: [PATCH] Update and rename SetHypervisoLaunch.ps1 to SetHypervisorLaunch.ps1 --- SetHypervisoLaunch.ps1 | 31 ------------------------------- SetHypervisorLaunch.ps1 | 31 +++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 31 deletions(-) delete mode 100644 SetHypervisoLaunch.ps1 create mode 100644 SetHypervisorLaunch.ps1 diff --git a/SetHypervisoLaunch.ps1 b/SetHypervisoLaunch.ps1 deleted file mode 100644 index ff76440..0000000 --- a/SetHypervisoLaunch.ps1 +++ /dev/null @@ -1,31 +0,0 @@ -Write-Host "[1] Set hypervisor launch option to auto (Hyper-V)" -Write-Host "[2] Set hypervisor launch option to off (VMWare)" - -$a = Read-Host -Prompt "Type your choice" - -$systemcheck = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) - -if ($systemcheck) { - if ($a -eq 1) { - Write-Host "[+] doing 'bcdedit /set hypervisorlaunchtype auto' command" - bcdedit /set hypervisorlaunchtype auto - $prompt = Read-Host -Prompt "[+} do you want to reboot? (y/n)" - if ($prompt -eq "y") { - Write-Host " [+] rebooting" - restart-computer -Confirm - } - } - elseif ($a -eq 2) { - Write-Host "[+] doing 'bcdedit /set hypervisorlaunchtype off' command" - bcdedit /set hypervisorlaunchtype off - $prompt = Read-Host -Prompt "[+} do you want to reboot? (y/n)" - if ($prompt -eq "y") { - Write-Host " [+] rebooting" - restart-computer -Confirm - } - } -} -else -{ - Write-Host "[+] not admin :(" -} diff --git a/SetHypervisorLaunch.ps1 b/SetHypervisorLaunch.ps1 new file mode 100644 index 0000000..31f3cc5 --- /dev/null +++ b/SetHypervisorLaunch.ps1 @@ -0,0 +1,31 @@ +Write-Host "[1] Set hypervisor launch option to auto (Hyper-V)" +Write-Host "[2] Set hypervisor launch option to off (VMWare)" + +$a = Read-Host -Prompt "Type your choice" +$hvType = @('auto', 'off') +$selType +$sysCheck = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) + +if ($sysCheck) { + if ($a -eq 1) { + $selType = $hvType[0] + } + elseif ($a -eq 2) { + $selType = $hvType[1] + } + if ($selType -eq 'auto' -or $selType -eq 'off') + { + Write-Host "[+] doing 'bcdedit /set hypervisorlaunchtype $selType' command" + bcdedit /set hypervisorlaunchtype $selType + $prompt = Read-Host -Prompt "[+] do you want to reboot? (y/n)" + + if ($prompt -eq "y") { + Write-Host " [+] rebooting" + restart-computer -Confirm + } + } +} +else +{ + Write-Host "[+] not admin :(" +}