Last active
July 1, 2018 15:17
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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