Skip to content

Instantly share code, notes, and snippets.

@ptflp
Last active July 1, 2018 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ptflp/3e2e9b6e5de3f7f3f57483db48a1cc67 to your computer and use it in GitHub Desktop.
Save ptflp/3e2e9b6e5de3f7f3f57483db48a1cc67 to your computer and use it in GitHub Desktop.
Set easy switching between Hyper-V and Virtualbox at startup. Run from powershell once, if you run multiple times, go to msconfig and delete excess entry.
param([switch]$Elevated)
function Check-Admin {
$currentUser = New-Object Security.Principal.WindowsPrincipal $([Security.Principal.WindowsIdentity]::GetCurrent())
$currentUser.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}
if ((Check-Admin) -eq $false) {
if ($elevated)
{
# could not elevate, quit
}
else {
Start-Process powershell.exe -Verb RunAs -ArgumentList ('-noprofile -noexit -file "{0}" -elevated' -f ($myinvocation.MyCommand.Definition))
}
exit
}
bcdedit /set "{current}" description "Windows 10 Hyper-V"
$str = bcdedit /copy "{current}" /d "Windows 10 VirtualBox"
$start = $str.indexOf("{")
$length = $str.indexOf("}")+1 - $start
$id = $str.substring($start, $length)
bcdedit /set $id hypervisorlaunchtype off
bcdedit /timeout 5
bcdedit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment