black electronics

Disable Windows Virtualization Security

A script for disabling VBS, Hyper-V and HVCI on your own testing host, not a target machine.

Windows features like Virtualization-Based Security (VBS), Credential Guard and Memory Integrity (HVCI) can conflict with nested virtualization, GPU passthrough or third-party hypervisors on a testing VM host — the machine you run your own lab VMs on, not a client system.

This script disables all of them so a testing host behaves predictably. Run it as administrator on your own machine and reboot afterwards.

Terminal window
# Disable hypervisor launch
bcdedit /set hypervisorlaunchtype off
# Remove Hyper-V and related virtualization features
$features = @(
"Microsoft-Hyper-V-All",
"HypervisorPlatform",
"IsolatedUserMode",
"VirtualMachinePlatform",
"WindowsHypervisorPlatform",
"Containers-DisposableClientVM",
"Windows-Defender-ApplicationGuard",
"Windows-Sandbox"
)
foreach ($f in $features) {
DISM /Online /Disable-Feature /FeatureName:$f /NoRestart
}
# Disable Device Guard and Credential Guard
reg add "HKLM\System\CurrentControlSet\Control\DeviceGuard" /v EnableVirtualizationBasedSecurity /t REG_DWORD /d 0 /f
reg add "HKLM\System\CurrentControlSet\Control\Lsa" /v LsaCfgFlags /t REG_DWORD /d 0 /f
reg delete "HKLM\System\CurrentControlSet\Control\DeviceGuard\Scenarios\HypervisorEnforcedCodeIntegrity" /f
# Disable VBS via policy
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\DeviceGuard" /v EnableVirtualizationBasedSecurity /t REG_DWORD /d 0 /f
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows\DeviceGuard" /v RequirePlatformSecurityFeatures /t REG_DWORD /d 0 /f
# Disable HVCI / Memory Integrity
reg add "HKLM\SYSTEM\CurrentControlSet\Control\DeviceGuard\Scenarios\HypervisorEnforcedCodeIntegrity" /v Enabled /t REG_DWORD /d 0 /f
reg add "HKLM\SYSTEM\CurrentControlSet\Control\CI\Policy" /v Enabled /t REG_DWORD /d 0 /f
# Disable mode-based execution control
reg add "HKLM\System\CurrentControlSet\Control\Lsa" /v ConfiguredRemoteAttestationLevel /t REG_DWORD /d 0 /f

A reboot is required for all of these changes to take effect.

Useful LinksPentest PayloadsCheat Sheets