Skip to content

Instantly share code, notes, and snippets.

@jkpl
Created March 27, 2021 20:57
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 jkpl/ee28137c578a89c7ef7166b463894126 to your computer and use it in GitHub Desktop.
Save jkpl/ee28137c578a89c7ef7166b463894126 to your computer and use it in GitHub Desktop.
param (
[Parameter(Mandatory=$false)]
[switch]$Disable
)
$script:regKeyPath = "HKLM\SYSTEM\CurrentControlSet\Control\DeviceGuard\Scenarios\HypervisorEnforcedCodeIntegrity"
If ($Disable) {
Write-Host "Disabling HyperV"
bcdedit /set hypervisorlaunchtype off
reg add $script:regKeyPath /v "Enabled" /t REG_DWORD /d 0 /f
} Else {
Write-Host "Enabling HyperV"
bcdedit /set hypervisorlaunchtype auto
reg delete $script:regKeyPath /f
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment