软件教程 关闭Windows基于虚拟化的安全性指北-全品牌通用方案 叶玖洛 2026-03-20
本文为受腾讯游戏安全ACE所扰用户常见的各种疑难杂症而诞生。
特别提醒:关闭虚拟化可能会降低系统安全性,会增加被恶意软件攻击的风险。建议仅在必要时进行,并确保安装可靠的安全软件来保护系统。关闭“基于虚拟化的安全性”主要是用以解决某些软件(如南方CASS、ENSP)等无法在虚拟化环境运行的问题,非必要不建议关闭!
使用dgreadiness工具关闭Windows虚拟化安全功能的完整流程 目录
背景介绍
工具准备
完整操作流程
注意事项
常见应用场景
背景介绍 Windows虚拟化安全功能概述 Windows虚拟化安全(Virtualization-Based Security,简称VBS)是一组基于硬件虚拟化技术的安全特性集合,利用CPU的虚拟化扩展能力(Intel VT-x/AMD-V)创建一个受保护的隔离环境,用于保护关键系统组件和敏感数据。
核心组件 1. 虚拟化安全(VBS)
VBS是整个虚拟化安全架构的基础设施
利用Windows Hypervisor创建虚拟安全模式(VSM)
在操作系统内核下方构建隔离的执行环境
2. Hypervisor强制代码完整性(HVCI)
俗称:内存完整性(Memory Integrity)
功能:将代码完整性检查隔离在VSM中执行
作用:防止恶意代码修改内核内存,确保只有经过验证的可信代码才能在内核模式下执行
防护目标:内核级漏洞利用、Rootkit、驱动程序攻击
3. 凭据保护(Credential Guard)
基于VBS保护敏感凭据信息
隔离本地安全机构(LSA)进程
防护目标:凭据窃取攻击(如Pass-the-Hash、Pass-the-Ticket)
4. 核心隔离(Core Isolation)
Windows 11中引入的用户界面概念
整合了内存完整性、内核隔离等功能
用户可通过Windows安全中心界面进行管理
工作原理 ┌─────────────────────────────────────────┐ │ Windows操作系统层 │ ├─────────────────────────────────────────┤ │ Windows Hypervisor (VMM) │ │ - 创建虚拟安全模式(VSM) │ │ - 内存隔离与访问控制 │ ├─────────────────────────────────────────┤ │ VSM内部安全组件: │ │ - HVCI(代码完整性检查) │ │ - Credential Guard(凭据保护) │ │ - 其他安全服务 │ ├─────────────────────────────────────────┤ │ 硬件虚拟化层 │ │ - Intel VT-x / AMD-V │ │ - SLAT(二级地址转换) │ │ - TPM 2.0(可信平台模块) │ └─────────────────────────────────────────┘
需要关闭VBS功能的典型场景 1. 虚拟化软件兼容性问题 问题表现:
VMware Workstation unrecoverable error: (vcpu-2) Exception 0x80000003 (debug breakpoint) has occurred. 或 VirtualBox错误: VT-x is disabled in the BIOS for all CPU modes (VERR_VMX_MSR_ALL_VMX_DISABLED)
原因分析:
Windows VBS占用了CPU的硬件虚拟化功能
第三方虚拟化软件(VMware、VirtualBox等)无法独占使用VT-x/AMD-V
导致虚拟机性能严重下降(约40%性能损失)或无法启动
影响范围:
VMware Workstation Pro/Player
Oracle VirtualBox
QEMU/KVM(Windows主机)
Android模拟器(HAXM)
Docker Desktop(基于WSL2)
2. 驱动程序兼容性问题 常见症状:
事件查看器中显示错误: Event ID: 3076 Code Integrity determined that a process (\Device\HarddiskVolume3\Windows\System32\drivers\incompatible_driver.sys) attempted to load non-Microsoft signed code that failed the HVCI policy check.
受影响驱动类型:
老旧硬件驱动程序(未经过HVCI兼容性认证)
自定义内核驱动(如某些游戏外设驱动)
专业设备驱动(工业控制、测量仪器等)
反作弊软件驱动(部分游戏反作弊系统)
3. 性能优化需求 性能影响:
场景
性能影响
说明
通用办公
0-5%
几乎无感知
CPU密集型任务
5-10%
编译、科学计算等
游戏性能
3-8%
取决于游戏类型
虚拟化场景
30-50%
与第三方虚拟化软件冲突
I/O密集型操作
5-15%
频繁的内存完整性检查
4. 特定应用要求 应用示例:
CASS11测绘软件(反调试机制与VBS冲突)
某些数字取证工具
逆向分析工具(需要直接访问底层硬件)
性能基准测试软件
5. 企业环境管理需求 管理场景:
统一的虚拟化平台部署
兼容性测试环境
开发调试环境
临时安全策略调整
工具准备 dgreadiness工具介绍 基本信息 官方名称: Device Guard and Credential Guard hardware readiness tool版本: 3.6发布日期: 2024年7月15日文件大小: 31.7 KB文件格式: dgreadiness_v3.6.zip
工具类型: PowerShell脚本工具
核心功能
就绪性检查(Capability Check)
检测硬件是否支持Device Guard/Credential Guard
验证BIOS/UEFI配置是否正确
检查驱动程序兼容性
状态查询(Status Check)
查询VBS当前运行状态
显示各安全组件启用情况
生成详细的兼容性报告
启用/禁用功能(Enable/Disable)
启用或禁用Device Guard
启用或禁用Credential Guard
启用或禁用HVCI(内存完整性)
HLK测试支持
检查设备是否通过Hardware Lab Kit测试
为驱动程序开发者提供测试支持
策略集成
支持自定义Code Integrity策略
可与System Center Configuration Manager集成
支持的操作系统
操作系统
版本要求
支持状态
Windows 10
1607及以上
✅ 完全支持
Windows 11
所有版本
✅ 完全支持
Windows Server 2016
所有版本
✅ 完全支持
Windows Server 2019
所有版本
✅ 完全支持
Windows Server 2022
所有版本
✅ 完全支持
工具获取方式 方法1:官方下载页(推荐) 下载步骤:
访问官方下载页面
点击跳转: https://www.microsoft.com/en-us/download/details.aspx?id=53337
选择语言
在页面顶部选择所需语言(如English)
页面内容会动态更新为所选语言
下载文件
点击”Download”按钮
选择”dgreadiness_v3.6.zip”文件
保存文件
方法2:命令行下载(高级用户) 使用PowerShell下载:
$downloadPath = "$env:USERPROFILE \Downloads" $downloadUrl = "https://download.microsoft.com/download/6/4/1/641C3FAF-2C49-45D6-8E8A-C8FD93B2F7C3/dgreadiness_v3.6.zip" $destination = "$downloadPath \dgreadiness_v3.6.zip" $webClient = New-Object System.Net.WebClient$webClient .DownloadFile($downloadUrl , $destination )Write-Host "下载完成,文件保存在: $destination " -ForegroundColor Green
使用curl下载(Windows 10 1803+):
curl -L -o "$env:USERPROFILE \Downloads\dgreadiness_v3.6.zip" https://download.microsoft.com/download/6 /4 /1 /641 C3FAF-2C49-45D6-8E8A-C8FD93B2F7C3 /dgreadiness_v3.6 .zip
安装步骤 步骤1:解压文件 Windows资源管理器方式:
导航到下载目录(如:C:\Users\YourName\Downloads)
右键点击dgreadiness_v3.6.zip
选择”全部提取(Extract All)”
选择目标目录(推荐:C:\Tools\dgreadiness_v3.6)
点击”提取”完成解压
PowerShell解压方式:
$sourcePath = "$env:USERPROFILE \Downloads\dgreadiness_v3.6.zip" $destinationPath = "C:\Tools\dgreadiness_v3.6" if (-not (Test-Path $destinationPath )) { New-Item -ItemType Directory -Path $destinationPath -Force } Expand-Archive -Path $sourcePath -DestinationPath $destinationPath -Force Write-Host "解压完成,文件保存在: $destinationPath " -ForegroundColor Green
步骤2:验证文件完整性 解压后应包含以下文件:
dgreadiness_v3.6/ ├── DG_Readiness_Tool_v3.6.ps1 # 主脚本文件 ├── readme.txt # 使用说明 └── DGLogs/ # 日志目录(运行后生成)
文件验证命令:
Get-ChildItem "C:\Tools\dgreadiness_v3.6" -Recurse $scriptPath = "C:\Tools\dgreadiness_v3.6\DG_Readiness_Tool_v3.6.ps1" if (Test-Path $scriptPath ) { Write-Host "✓ 主脚本文件存在" -ForegroundColor Green $fileInfo = Get-Item $scriptPath Write-Host " 文件大小: $ ($fileInfo .Length) 字节" -ForegroundColor Gray Write-Host " 修改时间: $ ($fileInfo .LastWriteTime)" -ForegroundColor Gray } else { Write-Host "✗ 主脚本文件不存在" -ForegroundColor Red }
步骤3:阅读使用说明 查看readme.txt:
notepad "C:\Tools\dgreadiness_v3.6\readme.txt" Get-Content "C:\Tools\dgreadiness_v3.6\readme.txt"
readme.txt主要内容摘要:
================================================================================ Device Guard and Credential Guard Hardware Readiness Tool Version 3.6 ================================================================================ USAGE: ------ DG_Readiness.ps1 -[Enable/Disable/Capable/Ready] -[DG/CG/HVCI/HLK] -Path <ConfigCI policy> -AutoReboot PARAMETERS: ----------- -Enable : Enable the specified feature -Disable : Disable the specified feature -Capable : Check if the device is capable of running the feature -Ready : Check if the device is ready to run the feature -DG : Device Guard -CG : Credential Guard -HVCI : Hypervisor-Enforced Code Integrity -HLK : Hardware Lab Kit tests -Path : Path to ConfigCI policy file -AutoReboot: Automatically reboot after configuration changes EXAMPLES: --------- # Check if device can run Device Guard .\DG_Readiness_Tool_v3.6.ps1 -Capable -DG # Enable HVCI .\DG_Readiness_Tool_v3.6.ps1 -Enable -HVCI # Disable Credential Guard .\DG_Readiness_Tool_v3.6.ps1 -Disable -CG # Check status of all features .\DG_Readiness_Tool_v3.6.ps1 -Ready -DG -CG -HVCI REQUIREMENTS: ------------- - Windows 10 version 1607 or later - Windows Server 2016 or later - Administrator privileges - PowerShell execution policy must allow script execution
工具基本功能说明 功能1:就绪性检查 检查设备是否支持Device Guard:
.\DG_Readiness_Tool_v3.6 .ps1 -Capable -DG
检查设备是否支持Credential Guard:
.\DG_Readiness_Tool_v3.6 .ps1 -Capable -CG
检查设备是否支持HVCI:
.\DG_Readiness_Tool_v3.6 .ps1 -Capable -HVCI
输出示例:
Device Guard Capability Check Results: Hardware Requirements: ======================= ✓ 64-bit processor: Supported ✓ Virtualization extensions: Supported ✓ Second Level Address Translation (SLAT): Supported ✓ UEFI 2.3.1 or later: Supported ✓ Secure Boot: Supported Software Requirements: ======================= ✓ Windows 10/11: Compatible ✓ TPM 2.0: Available Overall Status: CAPABLE
功能2:状态查询 查询Device Guard状态:
.\DG_Readiness_Tool_v3.6 .ps1 -Ready -DG
查询所有功能状态:
.\DG_Readiness_Tool_v3.6 .ps1 -Ready -DG -CG -HVCI
输出示例:
Current Status Report: Virtualization-Based Security: RUNNING - Base Virtualization Support: ENABLED - Secure Boot: ENABLED - DMA Protection: ENABLED Device Guard: ENABLED - Configurable Code Integrity: ENABLED - VSM Protected Code Integrity: ENABLED Credential Guard: ENABLED - LSA Isolation: RUNNING HVCI (Memory Integrity): ENABLED - Hypervisor Enforced Code Integrity: RUNNING
功能3:启用功能 启用Device Guard:
.\DG_Readiness_Tool_v3.6 .ps1 -Enable -DG -AutoReboot
启用Credential Guard:
.\DG_Readiness_Tool_v3.6 .ps1 -Enable -CG -AutoReboot
启用HVCI(内存完整性):
.\DG_Readiness_Tool_v3.6 .ps1 -Enable -HVCI -AutoReboot
功能4:禁用功能 禁用Device Guard:
.\DG_Readiness_Tool_v3.6 .ps1 -Disable -DG -AutoReboot
禁用Credential Guard:
.\DG_Readiness_Tool_v3.6 .ps1 -Disable -CG -AutoReboot
禁用HVCI(内存完整性):
.\DG_Readiness_Tool_v3.6 .ps1 -Disable -HVCI -AutoReboot
功能5:高级用法 使用自定义策略启用:
.\DG_Readiness_Tool_v3.6 .ps1 -Enable -DG -Path "C:\Policies\MyCIPolicy.p7b"
检查HLK测试就绪性:
.\DG_Readiness_Tool_v3.6 .ps1 -Capable -HLK
批量查询多台计算机(需要远程管理权限):
$computers = @ ("PC01" , "PC02" , "PC03" )foreach ($computer in $computers ) { Write-Host "Checking $computer ..." -ForegroundColor Cyan Invoke-Command -ComputerName $computer -ScriptBlock { & "C:\Tools\dgreadiness_v3.6\DG_Readiness_Tool_v3.6.ps1" -Ready -HVCI } }
完整操作流程 前置准备 步骤1:确认管理员权限 检查当前权限:
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity ]::GetCurrent())$isAdmin = $currentPrincipal .IsInRole([Security.Principal.WindowsBuiltInRole ]::Administrator)if ($isAdmin ) { Write-Host "✓ 当前具有管理员权限" -ForegroundColor Green } else { Write-Host "✗ 需要管理员权限,请以管理员身份重新运行PowerShell" -ForegroundColor Red Write-Host "提示:右键点击PowerShell,选择'以管理员身份运行'" -ForegroundColor Yellow exit }
方法2:使用UAC提示(如果非管理员):
if (!([Security.Principal.WindowsPrincipal ][Security.Principal.WindowsIdentity ]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole ] "Administrator" )) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath `"" -Verb RunAs exit }
步骤2:检查PowerShell执行策略 查看当前执行策略:
Get-ExecutionPolicy -List
输出示例:
MachinePolicy UserPolicy Process CurrentUser RemoteSigned LocalMachine Restricted
临时修改执行策略(仅当前会话):
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass -Force Write-Host "✓ 执行策略已设置为Bypass(仅当前会话)" -ForegroundColor Green
永久修改执行策略(不推荐):
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned -Force Write-Host "✓ 执行策略已设置为RemoteSigned" -ForegroundColor Green
步骤3:备份系统配置 创建系统还原点:
$systemProtection = Get-ComputerRestorePoint if ($systemProtection ) { Write-Host "✓ 系统保护已启用" -ForegroundColor Green } else { Write-Host "✗ 系统保护未启用,跳过还原点创建" -ForegroundColor Yellow } $description = "Before disabling VBS with dgreadiness" try { Checkpoint-Computer -Description $description -RestorePointType "MODIFY_SETTINGS" Write-Host "✓ 系统还原点创建成功: $description " -ForegroundColor Green } catch { Write-Host "✗ 创建还原点失败: $_ " -ForegroundColor Red }
导出当前注册表配置:
$backupDir = "C:\DGReadiness_Backup_$ (Get-Date -Format 'yyyyMMdd_HHmmss')" New-Item -ItemType Directory -Path $backupDir -Force | Out-Null $regPaths = @ ( "HKLM:\SYSTEM\CurrentControlSet\Control\DeviceGuard" , "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa" , "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" ) foreach ($path in $regPaths ) { $backupFile = "$backupDir \$ ($path .Replace('\', '_').Replace(':', '')).reg" try { reg export $path $backupFile /y Write-Host "✓ 已备份: $path " -ForegroundColor Green } catch { Write-Host "✗ 备份失败: $path " -ForegroundColor Red } } Write-Host "注册表备份完成,保存在: $backupDir " -ForegroundColor Cyan
导出BCD配置:
$bcdBackupFile = "$backupDir \BCD_Backup.txt" try { bcdedit /enum all > $bcdBackupFile Write -Host "✓ BCD 配置已备份: $bcdBackupFile " -ForegroundColor Green } catch { Write-Host "✗ BCD备份失败: $_ " -ForegroundColor Red }
步骤4:查看当前VBS状态 使用系统信息工具(msinfo32):
Start-Process msinfo32Get-CimInstance -ClassName Win32_DeviceGuard -Namespace root\Microsoft\Windows\DeviceGuard | Select-Object @ {N="基于虚拟化的安全性" ;E={$_ .VirtualizationBasedSecurityStatus}}, @ {N="安全服务运行中" ;E={$_ .SecurityServicesConfigured}}, @ {N="HVCI状态" ;E={$_ .SecurityServicesRunning}} | Format-List
使用PowerShell详细查询:
$vbsStatus = Get-CimInstance -ClassName Win32_DeviceGuard -Namespace root\Microsoft\Windows\DeviceGuardWrite-Host "当前VBS状态报告:" -ForegroundColor CyanWrite-Host "================================" -ForegroundColor GrayWrite-Host "基于虚拟化的安全性状态: $ ($vbsStatus .VirtualizationBasedSecurityStatus)" -ForegroundColor WhiteWrite-Host "已配置的安全服务: $ ($vbsStatus .SecurityServicesConfigured)" -ForegroundColor WhiteWrite-Host "正在运行的安全服务: $ ($vbsStatus .SecurityServicesRunning)" -ForegroundColor Whiteif ($vbsStatus .SecurityServicesRunning -band 1 ) { Write-Host "HVCI(内存完整性): 启用" -ForegroundColor Green } else { Write-Host "HVCI(内存完整性): 禁用" -ForegroundColor Red } if ($vbsStatus .SecurityServicesRunning -band 2 ) { Write-Host "Credential Guard: 启用" -ForegroundColor Green } else { Write-Host "Credential Guard: 禁用" -ForegroundColor Red }
使用Windows安全中心查看:
Start-Process "ms-settings:windowssecurity-coreisolation" Write-Host "请检查'核心隔离'页面中的'内存完整性'设置" -ForegroundColor Yellow
工具脚本使用详解 步骤5:导航到工具目录 方法1:使用cd命令:
Set-Location "C:\Tools\dgreadiness_v3.6" Write-Host "当前工作目录: $ (Get-Location)" -ForegroundColor Cyan
方法2:使用变量路径:
$dgToolPath = "C:\Tools\dgreadiness_v3.6" Set-Location $dgToolPath $scriptPath = Join-Path $dgToolPath "DG_Readiness_Tool_v3.6.ps1" if (Test-Path $scriptPath ) { Write-Host "✓ 工具脚本文件存在" -ForegroundColor Green } else { Write-Host "✗ 工具脚本文件不存在,请检查路径" -ForegroundColor Red exit }
步骤6:查看帮助信息 获取脚本帮助:
Get-Help .\DG_Readiness_Tool_v3.6 .ps1 -Full Get-Help .\DG_Readiness_Tool_v3.6 .ps1 -Parameter *
输出示例:
NAME DG_Readiness_Tool_v3.6.ps1 SYNOPSIS Device Guard and Credential Guard hardware readiness tool SYNTAX .\DG_Readiness_Tool_v3.6.ps1 [-Enable] [-Disable] [-Capable] [-Ready] [-DG] [-CG] [-HVCI] [-HLK] [-Path] [-AutoReboot] [<CommonParameters>] PARAMETERS -Enable Enable the specified feature -Disable Disable the specified feature -Capable Check if device is capable -Ready Check if device is ready -DG Device Guard -CG Credential Guard -HVCI Hypervisor-Enforced Code Integrity -HLK Hardware Lab Kit tests -Path ConfigCI policy path -AutoReboot Automatically reboot
步骤7:运行就绪性检查 检查HVCI就绪性:
Write-Host "开始HVCI就绪性检查..." -ForegroundColor Cyan.\DG_Readiness_Tool_v3.6 .ps1 -Capable -HVCI
检查所有功能就绪性:
Write-Host "开始全面就绪性检查..." -ForegroundColor Cyan.\DG_Readiness_Tool_v3.6 .ps1 -Capable -DG -CG -HVCI -HLK
分析检查结果:
检查完成后,工具会生成详细报告。主要关注以下信息:
=== HVCI Capability Check Results === Hardware Requirements: [✓] 64-bit processor [✓] Virtualization extensions (VT-x/AMD-V) [✓] Second Level Address Translation (SLAT) [✓] UEFI 2.3.1 or later [✓] Secure Boot [?] TPM 2.0 (Recommended but not required) Driver Compatibility: [!] Found 3 potentially incompatible drivers: - C:\Windows\System32\drivers\old_driver.sys (Version 1.0.0.1) - C:\Windows\System32\drivers\custom_device.sys (Version 2.3.0.0) - C:\Windows\System32\drivers\legacy_hardware.sys (Version 2019.01.01) Overall Status: CAPABLE WITH WARNINGS
如果显示”不兼容驱动”,需要先处理:
Get-CimInstance -ClassName Win32_PnPSignedDriver | Where-Object { $_ .DriverVersion -lt "2.0.0.0" } | Select-Object DeviceName, DriverVersion, DriverDate, InfName | Format-Table -AutoSize
步骤8:禁用VBS/HVCI功能 方法1:禁用整个VBS(推荐)
Write-Host "开始禁用虚拟化安全(VBS)..." -ForegroundColor CyanWrite-Host "警告:此操作将禁用以下功能:" -ForegroundColor YellowWrite-Host " - Device Guard" -ForegroundColor GrayWrite-Host " - Credential Guard" -ForegroundColor GrayWrite-Host " - HVCI(内存完整性)" -ForegroundColor GrayWrite-Host "" $confirmation = Read-Host "是否继续?(Y/N)" if ($confirmation -ne 'Y' -and $confirmation -ne 'y' ) { Write-Host "操作已取消" -ForegroundColor Yellow exit } Write-Host "执行禁用命令..." -ForegroundColor Cyan.\DG_Readiness_Tool_v3.6 .ps1 -Disable -AutoReboot Write-Host "命令执行完成,系统将自动重启" -ForegroundColor Green
方法2:仅禁用HVCI(内存完整性)
Write-Host "开始禁用HVCI(内存完整性)..." -ForegroundColor CyanWrite-Host "注意:Credential Guard等其他VBS功能将保持启用状态" -ForegroundColor YellowWrite-Host "" $confirmation = Read-Host "是否继续?(Y/N)" if ($confirmation -ne 'Y' -and $confirmation -ne 'y' ) { Write-Host "操作已取消" -ForegroundColor Yellow exit } Write-Host "执行禁用命令..." -ForegroundColor Cyan.\DG_Readiness_Tool_v3.6 .ps1 -Disable -HVCI -AutoReboot Write-Host "命令执行完成,系统将自动重启" -ForegroundColor Green
方法3:分步禁用(高级用户)
Write-Host "[1/3] 禁用Credential Guard..." -ForegroundColor Cyan.\DG_Readiness_Tool_v3.6 .ps1 -Disable -CG Write-Host "[2/3] 禁用HVCI..." -ForegroundColor Cyan.\DG_Readiness_Tool_v3.6 .ps1 -Disable -HVCI Write-Host "[3/3] 禁用Device Guard..." -ForegroundColor Cyan.\DG_Readiness_Tool_v3.6 .ps1 -Disable -DG -AutoReboot Write-Host "所有步骤完成,系统将自动重启" -ForegroundColor Green
步骤9:重启系统 自动重启(使用-AutoReboot参数):
手动重启:
Write-Host "当前时间: $ (Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" -ForegroundColor CyanWrite-Host "系统将在30秒后重启,请保存所有工作..." -ForegroundColor Yellowfor ($i = 30 ; $i -gt 0 ; $i -- ) { Write-Host "`r重启倒计时: $i 秒" -NoNewline Start-Sleep -Seconds 1 } Write-Host "`n正在重启系统..." -ForegroundColor GreenRestart-Computer -Force
带延迟的智能重启:
$importantProcesses = @ ("excel" , "winword" , "powerpnt" , "notepad" , "code" )$runningProcesses = Get-Process | Where-Object { $importantProcesses -contains $_ .ProcessName }if ($runningProcesses ) { Write-Host "检测到以下程序正在运行:" -ForegroundColor Yellow $runningProcesses | Select-Object ProcessName, MainWindowTitle | Format-Table $response = Read-Host "是否继续重启?(Y/N)" if ($response -ne 'Y' -and $response -ne 'y' ) { Write-Host "重启已取消,请手动关闭程序后重新运行脚本" -ForegroundColor Yellow exit } } Write-Host "正在重启系统..." -ForegroundColor GreenRestart-Computer -Force
处理”不安全”提示 问题1:PowerShell执行策略限制 错误信息:
.\DG_Readiness_Tool_v3.6.ps1 : 无法加载文件 DG_Readiness_Tool_v3.6.ps1,因为在此系统上禁止运行脚本。
解决方案:
Write-Host "当前执行策略:" -ForegroundColor CyanGet-ExecutionPolicy -List | Format-Table -AutoSize Write-Host "`n设置执行策略为Bypass(当前会话)..." -ForegroundColor YellowSet-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass -Force Write-Host "当前会话执行策略: $ (Get-ExecutionPolicy -Scope Process)" -ForegroundColor GreenWrite-Host "`n现在可以运行脚本了" -ForegroundColor Green
永久解决方案(谨慎使用):
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned -Force
问题2:UAC权限不足 错误信息:
解决方案1:自动提升权限
$selfElevateScript = @' # 检查是否具有管理员权限 $currentUser = [Security.Principal.WindowsIdentity]::GetCurrent() $principal = New-Object Security.Principal.WindowsPrincipal($currentUser) $isAdmin = $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) if (-not $isAdmin) { # 重新启动脚本,使用管理员权限 $arguments = "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" Start-Process powershell.exe -Verb RunAs -ArgumentList $arguments exit } # 这里放置实际的脚本代码 Write-Host "✓ 已获得管理员权限" -ForegroundColor Green '@ $tempScript = "$env:TEMP \SelfElevate.ps1" $selfElevateScript | Out-File -FilePath $tempScript -Encoding UTF8& $tempScript
解决方案2:手动以管理员身份运行
关闭当前的PowerShell窗口
按 Win + X 键
选择”Windows PowerShell (管理员)”或”终端 (管理员)”
导航到工具目录并运行脚本
问题3:Windows Defender拦截 错误信息:
Windows Defender已阻止此应用,因为它检测到潜在的不安全行为。
解决方案:
Start-Process "ms-settings:windowssecurity" $scriptPath = "C:\Tools\dgreadiness_v3.6" Add-MpPreference -ExclusionPath $scriptPath Write-Host "已将工具目录添加到Windows Defender排除项" -ForegroundColor GreenSet-MpPreference -DisableRealtimeMonitoring $true Write-Host "已临时关闭实时保护" -ForegroundColor YellowWrite-Host "警告:请在操作完成后重新启用实时保护" -ForegroundColor Red
通过GUI添加排除项:
打开Windows安全中心
点击”病毒和威胁防护”
点击”病毒和威胁防护设置”下的”管理设置”
向下滚动到”排除项”
点击”添加或删除排除项”
添加C:\Tools\dgreadiness_v3.6目录
问题4:组策略限制 错误信息:
解决方案:
$policyPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DeviceGuard" if (Test-Path $policyPath ) { Write-Host "检测到Device Guard组策略设置:" -ForegroundColor Yellow Get-ItemProperty -Path $policyPath | Format-List } $lsaPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa" $lsaFlags = (Get-ItemProperty -Path $lsaPath -ErrorAction SilentlyContinue).LsaCfgFlagsif ($lsaFlags ) { Write-Host "LSA隔离配置: $lsaFlags " -ForegroundColor Yellow Write-Host " 0 = 未启用" -ForegroundColor Gray Write-Host " 1 = 启用并使用UEFI锁" -ForegroundColor Gray Write-Host " 2 = 启用但不使用UEFI锁" -ForegroundColor Gray } if (Test-Path $policyPath ) { Write-Host "`n尝试临时禁用Device Guard组策略..." -ForegroundColor Cyan $backupPath = "$backupDir \GroupPolicy_Backup.reg" reg export "HKLM\SOFTWARE\Policies\Microsoft\Windows\DeviceGuard" $backupPath /y Set-ItemProperty -Path $policyPath -Name "EnableDeviceGuard" -Value 0 -ErrorAction SilentlyContinue Set-ItemProperty -Path $policyPath -Name "ConfigureSystemGuardLaunch" -Value 0 -ErrorAction SilentlyContinue Write-Host "组策略设置已临时修改" -ForegroundColor Green }
通过组策略编辑器修改:
按 Win + R,输入 gpedit.msc
导航到:计算机配置 → 管理模板 → 系统 → Device Guard
找到”启用基于虚拟化的安全性”
设置为”已禁用”
点击”应用”和”确定”
运行 gpupdate /force 更新组策略
问题5:SecConfig.efi启动菜单 问题描述: 重启后出现蓝色启动菜单,提示是否禁用Credential Guard/VBS。
解决方案:
Write-Host "系统重启后会出现启动选择菜单:" -ForegroundColor CyanWrite-Host "====================================" -ForegroundColor GrayWrite-Host "Credential Guard退出工具" -ForegroundColor WhiteWrite-Host "" -ForegroundColor WhiteWrite-Host "是否要禁用Credential Guard?" -ForegroundColor YellowWrite-Host "禁用此功能可能会允许恶意软件读取所有登录Windows" -ForegroundColor YellowWrite-Host "用户的密码和其他凭据。在禁用保护之前,请与您的" -ForegroundColor YellowWrite-Host "管理员联系以采取适合您组织的操作。" -ForegroundColor YellowWrite-Host "" -ForegroundColor WhiteWrite-Host "按Windows键或F3禁用Credential Guard,ESC跳过此步骤。" -ForegroundColor GreenWrite-Host "====================================" -ForegroundColor GrayWrite-Host "" Write-Host "操作步骤:" -ForegroundColor CyanWrite-Host "1. 按 F3 或 Windows键 选择禁用" -ForegroundColor WhiteWrite-Host "2. 等待系统完成配置" -ForegroundColor WhiteWrite-Host "3. 系统将再次重启并进入Windows" -ForegroundColor WhiteWrite-Host "" Write-Host "如果看到'基于虚拟化的安全性退出工具':" -ForegroundColor CyanWrite-Host "1. 同样按 F3 或 Windows键 选择禁用" -ForegroundColor WhiteWrite-Host "2. 按任意键继续" -ForegroundColor WhiteWrite-Host "3. 系统将完成禁用操作并重启" -ForegroundColor White
自动处理SecConfig.efi(高级方法):
Write-Host "检查EFI系统分区..." -ForegroundColor Cyan$espDrive = "X:" mountvol $espDrive /s if (Test-Path "$ {espDrive}\EFI\Microsoft\Boot" ) { Write-Host "✓ EFI分区已挂载到 $espDrive " -ForegroundColor Green $secConfigPath = "$ {espDrive}\EFI\Microsoft\Boot\SecConfig.efi" if (Test-Path $secConfigPath ) { Write-Host "✓ SecConfig.efi 存在" -ForegroundColor Green $guid = "{0cb3b571-2f2e-4343-a879-d86a476d7215}" bcdedit /create $guid /d "Disable VBS Tool" /application osloader bcdedit /set $guid path "\EFI\Microsoft\Boot\SecConfig.efi" bcdedit /set $guid device partition=$espDrive bcdedit /set $guid loadoptions DISABLE-VBS bcdedit /set {bootmgr} bootsequence $guid Write-Host "✓ 已创建VBS禁用启动项" -ForegroundColor Green } else { Write-Host "✗ SecConfig.efi 不存在" -ForegroundColor Red } mountvol $espDrive /d Write-Host "✓ EFI分区已卸载" -ForegroundColor Green } else { Write-Host "✗ 无法挂载EFI分区" -ForegroundColor Red }
验证操作结果 步骤10:验证VBS是否已禁用 方法1:使用系统信息工具
Start-Process msinfo32Write-Host "在系统信息窗口中查找以下内容:" -ForegroundColor CyanWrite-Host "1. 滚动到底部" -ForegroundColor WhiteWrite-Host "2. 查找'基于虚拟化的安全性'项目" -ForegroundColor WhiteWrite-Host "3. 确认状态为'未运行'(Not Running)" -ForegroundColor Green
方法2:使用PowerShell查询
Write-Host "VBS状态验证结果:" -ForegroundColor CyanWrite-Host "================================" -ForegroundColor Gray$dgStatus = Get-CimInstance -ClassName Win32_DeviceGuard -Namespace root\Microsoft\Windows\DeviceGuard$vbsStatus = $dgStatus .VirtualizationBasedSecurityStatusWrite-Host "基于虚拟化的安全性: " -NoNewline if ($vbsStatus -eq 0 ) { Write-Host "未运行 ✓" -ForegroundColor Green } else { Write-Host "正在运行 ✗" -ForegroundColor Red } $servicesConfigured = $dgStatus .SecurityServicesConfiguredWrite-Host "已配置的安全服务: $servicesConfigured " -ForegroundColor White$servicesRunning = $dgStatus .SecurityServicesRunningWrite-Host "正在运行的安全服务: $servicesRunning " -ForegroundColor WhiteWrite-Host "`n详细服务状态:" -ForegroundColor CyanWrite-Host "--------------------------------" -ForegroundColor Grayif ($servicesRunning -band 1 ) { Write-Host "HVCI(内存完整性): 启用 ✗" -ForegroundColor Red } else { Write-Host "HVCI(内存完整性): 禁用 ✓" -ForegroundColor Green } if ($servicesRunning -band 2 ) { Write-Host "Credential Guard: 启用 ✗" -ForegroundColor Red } else { Write-Host "Credential Guard: 禁用 ✓" -ForegroundColor Green } if ($dgStatus .Locked -eq 1 ) { Write-Host "写入保护: 启用 ✗" -ForegroundColor Red } else { Write-Host "写入保护: 禁用 ✓" -ForegroundColor Green }
方法3:使用Windows安全中心
Start-Process "ms-settings:windowssecurity-coreisolation" Write-Host "在核心隔离页面中检查:" -ForegroundColor CyanWrite-Host "1. 点击'核心隔离详细信息'" -ForegroundColor WhiteWrite-Host "2. 确认'内存完整性'开关为'关闭'" -ForegroundColor GreenWrite-Host "3. 如果显示'需要重启',请点击'立即重启'" -ForegroundColor Yellow
方法4:使用bcdedit命令
Write-Host "BCD启动配置验证:" -ForegroundColor CyanWrite-Host "================================" -ForegroundColor Gray$hypervisorType = bcdedit /enum | Select -String "hypervisorlaunchtype "Write -Host "Hypervisor 启动类型: " -NoNewline if ($hypervisorType -match "Off ") { Write-Host "关闭 ✓" -ForegroundColor Green } else { Write-Host "开启 ✗" -ForegroundColor Red } $vsmType = bcdedit /enum | Select -String "vsmlaunchtype "Write -Host "VSM 启动类型: " -NoNewline if ($vsmType -match "Off ") { Write-Host "关闭 ✓" -ForegroundColor Green } else { Write-Host "开启 ✗" -ForegroundColor Red }
步骤11:验证虚拟化功能释放 检查VT-x/AMD-V是否可用:
Write-Host "虚拟化功能验证:" -ForegroundColor CyanWrite-Host "================================" -ForegroundColor Gray$systemInfo = systeminfoif ($systemInfo -match "Hyper-V Requirements:.*A hypervisor has been detected" ) { Write-Host "Hyper-V Hypervisor: 检测到 ✗" -ForegroundColor Red Write-Host "说明:VBS可能未完全禁用" -ForegroundColor Yellow } else { Write-Host "Hyper-V Hypervisor: 未检测到 ✓" -ForegroundColor Green Write-Host "说明:虚拟化功能已释放" -ForegroundColor Green } $hypervisor = Get-CimInstance -ClassName Win32_ComputerSystem | Select-Object HypervisorPresentWrite-Host "HypervisorPresent: $ ($hypervisor .HypervisorPresent)" -ForegroundColor White$coreInfoPath = "C:\Tools\CoreInfo.exe" if (Test-Path $coreInfoPath ) { Write-Host "`n运行CoreInfo工具..." -ForegroundColor Cyan & $coreInfoPath }
使用第三方工具验证:
$intelUtil = Get-ChildItem -Path "C:\Program Files" , "C:\Program Files (x86)" -Recurse -Filter "IntelProcessorIdentificationUtility.exe" -ErrorAction SilentlyContinueif ($intelUtil ) { Write-Host "找到Intel处理器识别工具" -ForegroundColor Green Write-Host "路径: $ ($intelUtil .FullName)" -ForegroundColor Gray $response = Read-Host "是否启动工具查看虚拟化支持?(Y/N)" if ($response -eq 'Y' -or $response -eq 'y' ) { Start-Process $intelUtil .FullName } }
步骤12:生成验证报告 $reportPath = "C:\DGReadiness_Verification_$ (Get-Date -Format 'yyyyMMdd_HHmmss').txt" $reportContent = @ ()$reportContent += "dgreadiness工具禁用VBS操作验证报告" $reportContent += "=" * 50 $reportContent += "生成时间: $ (Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" $reportContent += "" $reportContent += "系统信息:" $reportContent += "-" * 30 $computerInfo = Get-CimInstance -ClassName Win32_ComputerSystem$reportContent += "计算机名: $ ($computerInfo .Name)" $reportContent += "操作系统: $ ((Get-CimInstance Win32_OperatingSystem).Caption)" $reportContent += "版本: $ ((Get-CimInstance Win32_OperatingSystem).Version)" $reportContent += "" $reportContent += "VBS状态:" $reportContent += "-" * 30 $dgStatus = Get-CimInstance -ClassName Win32_DeviceGuard -Namespace root\Microsoft\Windows\DeviceGuard$reportContent += "基于虚拟化的安全性: $ ($dgStatus .VirtualizationBasedSecurityStatus)" $reportContent += "已配置的安全服务: $ ($dgStatus .SecurityServicesConfigured)" $reportContent += "正在运行的安全服务: $ ($dgStatus .SecurityServicesRunning)" $reportContent += "HVCI状态: $ (if ($dgStatus .SecurityServicesRunning -band 1) { '启用' } else { '禁用' })" $reportContent += "Credential Guard状态: $ (if ($dgStatus .SecurityServicesRunning -band 2) { '启用' } else { '禁用' })" $reportContent += "" $reportContent += "BCD配置:" $reportContent += "-" * 30 $hypervisorType = bcdedit /enum | Select -String "hypervisorlaunchtype "$vsmType = bcdedit /enum | Select -String "vsmlaunchtype " $reportContent += $hypervisorType .Line $reportContent += $vsmType .Line $reportContent += "" # 添加总结 $reportContent += "操作总结:" $reportContent += "-" * 30 if ($dgStatus .VirtualizationBasedSecurityStatus -eq 0 -and $dgStatus .SecurityServicesRunning -eq 0) { $reportContent += "✓ VBS已成功禁用" $reportContent += "✓ 所有安全服务已停止" $reportContent += "✓ 虚拟化功能已释放" } else { $reportContent += "✗ VBS可能未完全禁用" $reportContent += "✗ 请检查日志文件或重新运行工具" } $reportContent | Out-File -FilePath $reportPath -Encoding UTF8Write-Host "验证报告已生成: $reportPath " -ForegroundColor GreenWrite-Host "报告内容:" -ForegroundColor CyanGet-Content $reportPath
步骤13:测试虚拟化软件 测试VMware Workstation:
$vmwarePath = "$ {env:ProgramFiles(x86)}\VMware\VMware Workstation\vmware.exe" if (Test-Path $vmwarePath ) { Write-Host "检测到VMware Workstation" -ForegroundColor Green $response = Read-Host "是否启动VMware进行测试?(Y/N)" if ($response -eq 'Y' -or $response -eq 'y' ) { Start-Process $vmwarePath Write-Host "VMware已启动" -ForegroundColor Green Write-Host "请尝试启动虚拟机,查看是否正常工作" -ForegroundColor Yellow Write-Host "如果虚拟机可以正常启动,说明VBS已成功禁用" -ForegroundColor Green } } else { Write-Host "未检测到VMware Workstation" -ForegroundColor Gray }
测试VirtualBox:
$virtualBoxPath = "$ {env:ProgramFiles}\Oracle\VirtualBox\VirtualBox.exe" if (Test-Path $virtualBoxPath ) { Write-Host "检测到VirtualBox" -ForegroundColor Green $response = Read-Host "是否启动VirtualBox进行测试?(Y/N)" if ($response -eq 'Y' -or $response -eq 'y' ) { Start-Process $virtualBoxPath Write-Host "VirtualBox已启动" -ForegroundColor Green Write-Host "请尝试启动虚拟机,查看是否正常工作" -ForegroundColor Yellow Write-Host "如果虚拟机可以正常启动,说明VBS已成功禁用" -ForegroundColor Green } } else { Write-Host "未检测到VirtualBox" -ForegroundColor Gray }
通用虚拟化测试脚本:
Write-Host "虚拟化功能测试:" -ForegroundColor CyanWrite-Host "================================" -ForegroundColor GrayWrite-Host "`n[测试1] Hyper-V服务状态" -ForegroundColor Cyan$hyperVServices = @ ("hvboot" , "HvHost" , "vmickvpexchange" , "vmicguestinterface" , "vmicshutdown" , "vmicheartbeat" , "vmicvmsession" , "vmicrdv" ) foreach ($service in $hyperVServices ) { $svc = Get-Service -Name $service -ErrorAction SilentlyContinue if ($svc ) { Write-Host "$service : $ ($svc .Status)" -ForegroundColor White } } Write-Host "`n[测试2] 虚拟机监控程序状态" -ForegroundColor Cyan$hypervisor = Get-CimInstance -ClassName Win32_ComputerSystemWrite-Host "HypervisorPresent: $ ($hypervisor .HypervisorPresent)" -ForegroundColor $ (if ($hypervisor .HypervisorPresent) { "Red" } else { "Green" })Write-Host "`n[测试3] CPU虚拟化支持" -ForegroundColor Cyan$cpu = Get-CimInstance -ClassName Win32_ProcessorWrite-Host "处理器: $ ($cpu .Name)" -ForegroundColor White$virtualizationEnabled = $false if ($cpu .SecondLevelAddressTranslationExtensions) { Write-Host "SLAT(二级地址转换): 支持" -ForegroundColor Green $virtualizationEnabled = $true } else { Write-Host "SLAT(二级地址转换): 不支持" -ForegroundColor Red } if ($cpu .VirtualizationFirmwareEnabled) { Write-Host "虚拟化固件: 启用" -ForegroundColor Green } else { Write-Host "虚拟化固件: 禁用" -ForegroundColor Red } Write-Host "`n测试总结:" -ForegroundColor CyanWrite-Host "================================" -ForegroundColor Grayif (-not $hypervisor .HypervisorPresent -and $virtualizationEnabled ) { Write-Host "✓ 虚拟化功能已成功释放" -ForegroundColor Green Write-Host "✓ 可以正常使用第三方虚拟化软件" -ForegroundColor Green } else { Write-Host "✗ 虚拟化功能可能未完全释放" -ForegroundColor Red Write-Host "✗ 建议重新运行dgreadiness工具" -ForegroundColor Yellow }
恢复操作(如需重新启用) 步骤14:重新启用VBS功能 使用dgreadiness工具重新启用:
Set-Location "C:\Tools\dgreadiness_v3.6" Write-Host "开始重新启用虚拟化安全..." -ForegroundColor Cyan.\DG_Readiness_Tool_v3.6 .ps1 -Enable -AutoReboot Write-Host "命令执行完成,系统将自动重启" -ForegroundColor Green
仅重新启用HVCI:
Write-Host "开始重新启用HVCI(内存完整性)..." -ForegroundColor Cyan.\DG_Readiness_Tool_v3.6 .ps1 -Enable -HVCI -AutoReboot Write-Host "命令执行完成,系统将自动重启" -ForegroundColor Green
通过Windows安全中心启用:
Start-Process "ms-settings:windowssecurity-coreisolation" Write-Host "在核心隔离页面中:" -ForegroundColor CyanWrite-Host "1. 点击'核心隔离详细信息'" -ForegroundColor WhiteWrite-Host "2. 打开'内存完整性'开关" -ForegroundColor WhiteWrite-Host "3. 点击'立即重启'" -ForegroundColor White
恢复注册表备份:
$backupDirs = Get-ChildItem -Path "C:\" -Filter "DGReadiness_Backup_*" | Sort-Object LastWriteTime -Descending if ($backupDirs .Count -gt 0 ) { $latestBackup = $backupDirs [0 ].FullName Write-Host "找到最新备份: $latestBackup " -ForegroundColor Green $response = Read-Host "是否恢复注册表备份?(Y/N)" if ($response -eq 'Y' -or $response -eq 'y' ) { $regFiles = Get-ChildItem -Path $latestBackup -Filter "*.reg" foreach ($regFile in $regFiles ) { Write-Host "正在恢复: $ ($regFile .Name)" -ForegroundColor Cyan reg import $regFile .FullName } Write-Host "注册表备份已恢复,需要重启系统" -ForegroundColor Green $response = Read-Host "是否立即重启?(Y/N)" if ($response -eq 'Y' -or $response -eq 'y' ) { Restart-Computer } } } else { Write-Host "未找到备份目录" -ForegroundColor Yellow }
注意事项 操作风险警告 1. 安全性降低风险 风险描述: 禁用VBS/HVCI会显著降低系统的安全防护能力,使系统更容易受到以下攻击:
攻击类型
风险等级
说明
内核级Rootkit
🔴 高
恶意代码可直接修改内核内存
驱动程序漏洞利用
🔴 高
未签名驱动可被恶意利用
凭据窃取
🔴 高
Credential Guard禁用后,LSA保护减弱
内存破坏攻击
🔴 高
W+X内存页面可能被滥用
零日漏洞利用
🟡 中HVCI可阻止的部分攻击面将暴露
安全建议:
Write-Host "建议采取的补充安全措施:" -ForegroundColor CyanWrite-Host "1. 确保Windows Defender实时保护始终启用" -ForegroundColor WhiteWrite-Host "2. 定期更新系统和驱动程序" -ForegroundColor WhiteWrite-Host "3. 仅从可信来源安装软件" -ForegroundColor WhiteWrite-Host "4. 使用强密码和多因素认证" -ForegroundColor WhiteWrite-Host "5. 定期备份重要数据" -ForegroundColor WhiteWrite-Host "6. 限制管理员账户使用" -ForegroundColor WhiteWrite-Host "7. 启用网络防火墙" -ForegroundColor White
2. 功能依赖风险 受影响的Windows功能:
Write-Host "禁用VBS后,以下功能可能无法使用:" -ForegroundColor YellowWrite-Host "================================" -ForegroundColor GrayWrite-Host "✗ Windows Defender Credential Guard" -ForegroundColor RedWrite-Host "✗ Windows Defender Application Guard" -ForegroundColor RedWrite-Host "✗ Windows Sandbox(Windows沙盒)" -ForegroundColor RedWrite-Host "✗ WSL2(Windows子系统 for Linux 2)" -ForegroundColor RedWrite-Host "✗ 某些Windows Hello功能" -ForegroundColor RedWrite-Host "✗ 内存完整性保护" -ForegroundColor RedWrite-Host "✗ 内核隔离功能" -ForegroundColor Red
检查依赖功能:
Write-Host "检查Windows功能状态:" -ForegroundColor Cyan$features = @ ( @ {Name="Containers-DisposableClientVM" ; Desc="Windows Sandbox" }, @ {Name="Microsoft-Hyper-V-All" ; Desc="Hyper-V" }, @ {Name="VirtualMachinePlatform" ; Desc="虚拟机平台" }, @ {Name="Windows-Defender-ApplicationGuard" ; Desc="Application Guard" } ) foreach ($feature in $features ) { $state = Get-WindowsOptionalFeature -Online -FeatureName $feature .Name -ErrorAction SilentlyContinue if ($state -and $state .State -eq "Enabled" ) { Write-Host "$ ($feature .Desc): 启用" -ForegroundColor Yellow Write-Host " 注意:此功能可能受影响" -ForegroundColor Gray } }
3. 系统稳定性风险 可能遇到的问题:
驱动程序加载异常
Write-Host "监控驱动加载错误(事件查看器):" -ForegroundColor CyanGet-WinEvent -FilterHashtable @ { LogName = 'System' ProviderName = 'Microsoft-Windows-DriverFrameworks-UserMode' Level = 2 } -MaxEvents 10 | Format-List TimeCreated, Message
系统更新失败
Write-Host "检查Windows更新历史:" -ForegroundColor CyanGet-WindowsUpdateLog | Select-String "Error" , "Failed" | Select-Object -First 10
性能回归
Write-Host "建议进行性能基准测试:" -ForegroundColor CyanWrite-Host "1. 使用PCMark 10进行综合性能测试" -ForegroundColor WhiteWrite-Host "2. 使用CrystalDiskMark测试磁盘性能" -ForegroundColor WhiteWrite-Host "3. 使用3DMark测试图形性能" -ForegroundColor WhiteWrite-Host "4. 记录禁用前后的性能数据对比" -ForegroundColor White
系统要求 硬件要求
组件
最低要求
推荐配置
说明
处理器
64位CPU
Intel Core i5 / AMD Ryzen 5及以上
必须支持虚拟化扩展
虚拟化支持
Intel VT-x / AMD-V
-
BIOS中必须启用
SLAT
Intel EPT / AMD RVI
-
二级地址转换
内存
4GB
8GB及以上
VBS占用约1-2GB内存
TPM
TPM 1.2
TPM 2.0
Credential Guard需要TPM 2.0
固件
UEFI 2.3.1
最新UEFI版本
必须支持Secure Boot
存储
20GB可用空间
50GB及以上
用于日志和备份
检查硬件兼容性:
Write-Host "硬件兼容性检查:" -ForegroundColor CyanWrite-Host "================================" -ForegroundColor Gray$cpu = Get-CimInstance -ClassName Win32_ProcessorWrite-Host "处理器信息:" -ForegroundColor YellowWrite-Host " 名称: $ ($cpu .Name)" -ForegroundColor WhiteWrite-Host " 架构: $ ($cpu .Architecture)" -ForegroundColor WhiteWrite-Host " 核心数: $ ($cpu .NumberOfCores)" -ForegroundColor WhiteWrite-Host " 虚拟化: $ (if ($cpu .VirtualizationFirmwareEnabled) { '启用' } else { '禁用' })" -ForegroundColor $ (if ($cpu .VirtualizationFirmwareEnabled) { "Green" } else { "Red" })Write-Host " SLAT: $ (if ($cpu .SecondLevelAddressTranslationExtensions) { '支持' } else { '不支持' })" -ForegroundColor $ (if ($cpu .SecondLevelAddressTranslationExtensions) { "Green" } else { "Red" })$memory = Get-CimInstance -ClassName Win32_PhysicalMemory$totalMemory = ($memory | Measure-Object -Property Capacity -Sum ).Sum / 1 GBWrite-Host "`n内存信息:" -ForegroundColor YellowWrite-Host " 总容量: $ ([math]::Round($totalMemory , 2)) GB" -ForegroundColor Whiteif ($totalMemory -lt 4 ) { Write-Host " 警告:内存低于最低要求" -ForegroundColor Red } elseif ($totalMemory -lt 8 ) { Write-Host " 提示:建议升级到8GB或更多" -ForegroundColor Yellow } else { Write-Host " 状态:满足推荐配置" -ForegroundColor Green } $tpm = Get-CimInstance -ClassName Win32_Tpm -Namespace root\cimv2\security\microsofttpm -ErrorAction SilentlyContinueif ($tpm ) { Write-Host "`nTPM信息:" -ForegroundColor Yellow Write-Host " 版本: $ ($tpm .SpecVersion)" -ForegroundColor White Write-Host " 状态: $ (if ($tpm .IsEnabled_InitialValue) { '启用' } else { '禁用' })" -ForegroundColor $ (if ($tpm .IsEnabled_InitialValue) { "Green" } else { "Red" }) if ($tpm .SpecVersion -match "2\.0" ) { Write-Host " 状态:支持Credential Guard" -ForegroundColor Green } else { Write-Host " 提示:建议升级到TPM 2.0" -ForegroundColor Yellow } } else { Write-Host "`nTPM信息:未检测到TPM" -ForegroundColor Red } $firmware = Get-CimInstance -ClassName Win32_BIOSWrite-Host "`n固件信息:" -ForegroundColor YellowWrite-Host " 版本: $ ($firmware .SMBIOSBIOSVersion)" -ForegroundColor WhiteWrite-Host " 日期: $ ($firmware .ReleaseDate)" -ForegroundColor Whitetry { $secureBoot = Confirm-SecureBootUEFI Write-Host " Secure Boot: 启用" -ForegroundColor Green } catch { Write-Host " Secure Boot: 禁用或无法检测" -ForegroundColor Yellow } $systemDrive = Get-PSDrive -Name C$freeSpaceGB = $systemDrive .Free / 1 GBWrite-Host "`n磁盘空间(C盘):" -ForegroundColor YellowWrite-Host " 可用空间: $ ([math]::Round($freeSpaceGB , 2)) GB" -ForegroundColor Whiteif ($freeSpaceGB -lt 20 ) { Write-Host " 警告:可用空间不足20GB" -ForegroundColor Red } elseif ($freeSpaceGB -lt 50 ) { Write-Host " 提示:建议保持至少50GB可用空间" -ForegroundColor Yellow } else { Write-Host " 状态:满足要求" -ForegroundColor Green }
软件要求
软件
最低版本
推荐版本
说明
Windows 10
1607
21H2或更新
家庭版/专业版/企业版
Windows 11
21H2
23H2或更新
家庭版/专业版/企业版
Windows Server 2016
14393
最新更新版
标准版/数据中心版
Windows Server 2019
17763
最新更新版
标准版/数据中心版
Windows Server 2022
20348
最新更新版
标准版/数据中心版
PowerShell
5.1
7.x或更新
用于运行工具脚本
.NET Framework
4.7.2
4.8或更新
某些组件依赖
检查系统版本:
Write-Host "系统版本检查:" -ForegroundColor CyanWrite-Host "================================" -ForegroundColor Gray$os = Get-CimInstance -ClassName Win32_OperatingSystemWrite-Host "操作系统: $ ($os .Caption)" -ForegroundColor WhiteWrite-Host "版本: $ ($os .Version)" -ForegroundColor WhiteWrite-Host "构建号: $ ($os .BuildNumber)" -ForegroundColor WhiteWrite-Host "服务包: $ ($os .ServicePackMajorVersion).$ ($os .ServicePackMinorVersion)" -ForegroundColor White$buildNumber = [int ]$os .BuildNumberWrite-Host "`n版本分析:" -ForegroundColor Yellowif ($os .Caption -match "Windows 11" ) { if ($buildNumber -ge 26100 ) { Write-Host " Windows 11 24H2/25H2 - 最新版本" -ForegroundColor Green } elseif ($buildNumber -ge 22631 ) { Write-Host " Windows 11 23H2" -ForegroundColor Green } elseif ($buildNumber -ge 22000 ) { Write-Host " Windows 11 21H2/22H2" -ForegroundColor Green } } elseif ($os .Caption -match "Windows 10" ) { if ($buildNumber -ge 19045 ) { Write-Host " Windows 10 22H2" -ForegroundColor Green } elseif ($buildNumber -ge 19044 ) { Write-Host " Windows 10 21H2" -ForegroundColor Green } elseif ($buildNumber -ge 14393 ) { Write-Host " Windows 10 1607-21H1" -ForegroundColor Yellow } } elseif ($os .Caption -match "Windows Server" ) { if ($buildNumber -ge 20348 ) { Write-Host " Windows Server 2022" -ForegroundColor Green } elseif ($buildNumber -ge 17763 ) { Write-Host " Windows Server 2019" -ForegroundColor Green } elseif ($buildNumber -ge 14393 ) { Write-Host " Windows Server 2016" -ForegroundColor Yellow } } Write-Host "`nPowerShell版本:" -ForegroundColor Yellow$psVersion = $PSVersionTable .PSVersionWrite-Host " 版本: $ ($psVersion .Major).$ ($psVersion .Minor).$ ($psVersion .Build)" -ForegroundColor WhiteWrite-Host " 版本: $ ($PSVersionTable .PSEdition)" -ForegroundColor Whiteif ($psVersion .Major -ge 7 ) { Write-Host " 状态:使用PowerShell 7+,推荐" -ForegroundColor Green } else { Write-Host " 提示:建议升级到PowerShell 7" -ForegroundColor Yellow } Write-Host "`n.NET Framework版本:" -ForegroundColor Yellow$netVersions = Get-ChildItem "HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" -ErrorAction SilentlyContinueif ($netVersions ) { $release = (Get-ItemProperty $netVersions .PSPath).Release Write-Host " Release: $release " -ForegroundColor White if ($release -ge 528040 ) { Write-Host " 版本:4.8或更新 - 满足要求" -ForegroundColor Green } elseif ($release -ge 461808 ) { Write-Host " 版本:4.7.2 - 满足最低要求" -ForegroundColor Yellow } else { Write-Host " 版本:低于4.7.2 - 不满足要求" -ForegroundColor Red } } else { Write-Host " 状态:未检测到.NET Framework 4.x" -ForegroundColor Red }
恢复方法 方法1:使用dgreadiness工具重新启用 重新启用所有VBS功能:
Set-Location "C:\Tools\dgreadiness_v3.6" Write-Host "开始重新启用虚拟化安全功能..." -ForegroundColor CyanWrite-Host "此操作将恢复以下功能:" -ForegroundColor YellowWrite-Host " - Device Guard" -ForegroundColor GrayWrite-Host " - Credential Guard" -ForegroundColor GrayWrite-Host " - HVCI(内存完整性)" -ForegroundColor GrayWrite-Host "" $confirmation = Read-Host "是否继续?(Y/N)" if ($confirmation -ne 'Y' -and $confirmation -ne 'y' ) { Write-Host "操作已取消" -ForegroundColor Yellow exit } Write-Host "执行启用命令..." -ForegroundColor Cyan.\DG_Readiness_Tool_v3.6 .ps1 -Enable -AutoReboot Write-Host "命令执行完成,系统将自动重启" -ForegroundColor Green
仅重新启用HVCI:
Write-Host "开始重新启用HVCI(内存完整性)..." -ForegroundColor CyanWrite-Host "注意:仅恢复内存完整性保护" -ForegroundColor YellowWrite-Host "" $confirmation = Read-Host "是否继续?(Y/N)" if ($confirmation -ne 'Y' -and $confirmation -ne 'y' ) { Write-Host "操作已取消" -ForegroundColor Yellow exit } Write-Host "执行启用命令..." -ForegroundColor Cyan.\DG_Readiness_Tool_v3.6 .ps1 -Enable -HVCI -AutoReboot Write-Host "命令执行完成,系统将自动重启" -ForegroundColor Green
方法2:通过组策略恢复 恢复Device Guard组策略:
Start-Process gpedit.mscWrite-Host "在组策略编辑器中:" -ForegroundColor CyanWrite-Host "1. 导航到:计算机配置 → 管理模板 → 系统 → Device Guard" -ForegroundColor WhiteWrite-Host "2. 找到'启用基于虚拟化的安全性'" -ForegroundColor WhiteWrite-Host "3. 设置为'未配置'或'已启用'" -ForegroundColor WhiteWrite-Host "4. 点击'应用'和'确定'" -ForegroundColor WhiteWrite-Host "5. 运行以下命令更新组策略:" -ForegroundColor YellowWrite-Host " gpupdate /force" -ForegroundColor Gray
更新组策略:
Write-Host "正在更新组策略..." -ForegroundColor Cyangpupdate /force Write-Host "组策略已更新,建议重启系统" -ForegroundColor Green
方法3:通过注册表恢复 恢复Device Guard注册表项:
Write-Host "恢复Device Guard注册表配置..." -ForegroundColor Cyan$deviceGuardPath = "HKLM:\SYSTEM\CurrentControlSet\Control\DeviceGuard" Set-ItemProperty -Path $deviceGuardPath -Name "EnableVirtualizationBasedSecurity" -Value 1 -Type DWord -ErrorAction SilentlyContinueSet-ItemProperty -Path $deviceGuardPath -Name "RequirePlatformSecurityFeatures" -Value 1 -Type DWord -ErrorAction SilentlyContinue$hvciPath = "$deviceGuardPath \Scenarios\HypervisorEnforcedCodeIntegrity" Set-ItemProperty -Path $hvciPath -Name "Enabled" -Value 1 -Type DWord -ErrorAction SilentlyContinue$lsaPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa" Set-ItemProperty -Path $lsaPath -Name "LsaCfgFlags" -Value 1 -Type DWord -ErrorAction SilentlyContinueWrite-Host "注册表配置已恢复" -ForegroundColor GreenWrite-Host "需要重启系统以使更改生效" -ForegroundColor Yellow
恢复BCD配置:
Write-Host "恢复BCD配置..." -ForegroundColor Cyanbcdedit /set hypervisorlaunchtype auto bcdedit /set vsmlaunchtype auto Write-Host "BCD配置已恢复" -ForegroundColor GreenWrite-Host "需要重启系统以使更改生效" -ForegroundColor Yellow
方法4:从备份恢复 恢复之前创建的备份:
$backupDirs = Get-ChildItem -Path "C:\" -Filter "DGReadiness_Backup_*" | Sort-Object LastWriteTime -Descending if ($backupDirs .Count -gt 0 ) { $latestBackup = $backupDirs [0 ].FullName Write-Host "找到最新备份: $latestBackup " -ForegroundColor Green Write-Host "`n备份内容:" -ForegroundColor Cyan Get-ChildItem -Path $latestBackup | Format-Table Name, Length, LastWriteTime -AutoSize $response = Read-Host "是否恢复此备份?(Y/N)" if ($response -eq 'Y' -or $response -eq 'y' ) { $regFiles = Get-ChildItem -Path $latestBackup -Filter "*.reg" Write-Host "`n正在恢复注册表备份..." -ForegroundColor Cyan foreach ($regFile in $regFiles ) { Write-Host "恢复: $ ($regFile .Name)" -ForegroundColor White reg import $regFile .FullName } Write-Host "注册表备份已恢复" -ForegroundColor Green $bcdBackup = Get-ChildItem -Path $latestBackup -Filter "BCD_Backup.txt" if ($bcdBackup ) { Write-Host "`nBCD配置备份内容:" -ForegroundColor Cyan Get-Content $bcdBackup .FullName | Select-Object -First 20 $response = Read-Host "是否手动恢复BCD配置?(Y/N)" if ($response -eq 'Y' -or $response -eq 'y' ) { Write-Host "请根据备份内容手动执行BCD命令" -ForegroundColor Yellow } } Write-Host "`n备份恢复完成,需要重启系统" -ForegroundColor Green $response = Read-Host "是否立即重启?(Y/N)" if ($response -eq 'Y' -or $response -eq 'y' ) { Restart-Computer } } } else { Write-Host "未找到备份目录" -ForegroundColor Yellow }
方法5:使用系统还原点 恢复到之前的系统还原点:
Write-Host "可用的系统还原点:" -ForegroundColor CyanWrite-Host "================================" -ForegroundColor Gray$restorePoints = Get-ComputerRestorePoint | Sort-Object CreationTime -Descending $restorePoints | Select-Object @ {N="序号" ;E={$global:i =0 }{$global:i ++;$global:i }}, SequenceNumber, Description, CreationTime, @ {N="类型" ;E={$_ .RestorePointType}} | Format-Table -AutoSize if ($restorePoints .Count -gt 0 ) { Write-Host "`n输入要恢复的还原点序号(0取消):" -NoNewline $selection = Read-Host if ($selection -match "^\d+$ " -and [int ]$selection -gt 0 -and [int ]$selection -le $restorePoints .Count) { $selectedPoint = $restorePoints [[int ]$selection - 1 ] Write-Host "`n选中的还原点:" -ForegroundColor Cyan Write-Host " 描述: $ ($selectedPoint .Description)" -ForegroundColor White Write-Host " 时间: $ ($selectedPoint .CreationTime)" -ForegroundColor White $confirmation = Read-Host "`n确认恢复到此还原点?此操作不可撤销(Y/N)" if ($confirmation -eq 'Y' -or $confirmation -eq 'y' ) { Write-Host "正在系统还原..." -ForegroundColor Cyan Restore-Computer -RestorePoint $selectedPoint .SequenceNumber Write-Host "系统还原已启动,计算机将重启" -ForegroundColor Green Start-Sleep -Seconds 5 Restart-Computer } } else { Write-Host "操作已取消" -ForegroundColor Yellow } } else { Write-Host "没有可用的系统还原点" -ForegroundColor Yellow }
备份建议 关键备份项清单 Write-Host "创建完整备份..." -ForegroundColor Cyan$backupRoot = "C:\DGReadiness_Backup_$ (Get-Date -Format 'yyyyMMdd_HHmmss')" New-Item -ItemType Directory -Path $backupRoot -Force | Out-Null Write-Host "备份目录: $backupRoot " -ForegroundColor GreenWrite-Host "`n[1/5] 备份注册表..." -ForegroundColor Cyan$regBackupDir = "$backupRoot \Registry" New-Item -ItemType Directory -Path $regBackupDir -Force | Out-Null $regPaths = @ ( "HKLM:\SYSTEM\CurrentControlSet\Control\DeviceGuard" , "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa" , "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Device Guard" , "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" ) foreach ($path in $regPaths ) { $fileName = $path .Replace('\' , '_' ).Replace(':' , '' ) + ".reg" $filePath = Join-Path $regBackupDir $fileName reg export $path $filePath /y Write-Host " 已备份: $path " -ForegroundColor Green } Write-Host "`n[2/5] 备份BCD配置..." -ForegroundColor Cyan$bcdBackup = "$backupRoot \BCD_Configuration.txt" bcdedit /enum all > $bcdBackup Write -Host " 已备份: BCD 配置" -ForegroundColor Green # 4. 备份系统信息 Write -Host "`n [3/5] 备份系统信息..." -ForegroundColor Cyan $sysInfoBackup = "$backupRoot \System_Info .txt " systeminfo > $sysInfoBackup Write -Host " 已备份: 系统信息" -ForegroundColor Green # 5. 备份当前VBS 状态 Write -Host "`n [4/5] 备份VBS 状态..." -ForegroundColor Cyan $vbsBackup = "$backupRoot \VBS_Status .txt " $vbsStatus = Get -CimInstance -ClassName Win32_DeviceGuard -Namespace root \Microsoft \Windows \DeviceGuard $vbsStatus | Out -File -FilePath $vbsBackup Write -Host " 已备份: VBS 状态" -ForegroundColor Green # 6. 创建系统还原点 Write -Host "`n [5/5] 创建系统还原点..." -ForegroundColor Cyan $restorePointDesc = "Before DGReadiness Operation - $(Get -Date -Format 'yyyy -MM -dd HH :mm :ss ')" try { Checkpoint-Computer -Description $restorePointDesc -RestorePointType "MODIFY_SETTINGS" Write-Host " 已创建系统还原点" -ForegroundColor Green } catch { Write-Host " 系统还原点创建失败: $_ " -ForegroundColor Red } Write-Host "`n生成备份清单..." -ForegroundColor Cyan$manifestPath = "$backupRoot \Backup_Manifest.txt" $manifestContent = @" dgreadiness操作备份清单 ================================ 备份时间: $ (Get-Date -Format 'yyyy-MM-dd HH:mm:ss') 备份目录: $backupRoot 备份内容: -------- 1. 注册表备份: $ (Join-Path $backupRoot "Registry") 2. BCD配置: $bcdBackup 3. 系统信息: $sysInfoBackup 4. VBS状态: $vbsBackup 5. 系统还原点: $restorePointDesc 备份文件列表: -------- "@ Get-ChildItem -Path $backupRoot -Recurse | ForEach-Object { $manifestContent += "$ ($_ .FullName)`r`n" } $manifestContent | Out-File -FilePath $manifestPath Write-Host " 已生成备份清单" -ForegroundColor GreenWrite-Host "`n================================" -ForegroundColor GrayWrite-Host "备份完成!" -ForegroundColor GreenWrite-Host "备份目录: $backupRoot " -ForegroundColor CyanWrite-Host "备份清单: $manifestPath " -ForegroundColor CyanWrite-Host "" Write-Host "建议:将备份目录复制到外部存储设备" -ForegroundColor Yellow
自动化备份脚本 创建定时备份任务:
$backupScript = @' # 自动备份脚本 $backupRoot = "C:\DGReadiness_AutoBackup_$(Get-Date -Format 'yyyyMMdd')" New-Item -ItemType Directory -Path $backupRoot -Force | Out-Null # 备份注册表 $regBackupDir = "$backupRoot\Registry" New-Item -ItemType Directory -Path $regBackupDir -Force | Out-Null $regPaths = @( "HKLM:\SYSTEM\CurrentControlSet\Control\DeviceGuard", "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa" ) foreach ($path in $regPaths) { $fileName = $path.Replace('\', '_').Replace(':', '') + ".reg" $filePath = Join-Path $regBackupDir $fileName reg export $path $filePath /y } # 备份VBS状态 $vbsBackup = "$backupRoot\VBS_Status.txt" Get-CimInstance -ClassName Win32_DeviceGuard -Namespace root\Microsoft\Windows\DeviceGuard | Out-File -FilePath $vbsBackup # 清理30天前的旧备份 $oldBackups = Get-ChildItem -Path "C:\" -Filter "DGReadiness_AutoBackup_*" | Where-Object { $_.LastWriteTime -lt (Get-Date).AddDays(-30) } foreach ($oldBackup in $oldBackups) { Remove-Item -Path $oldBackup.FullName -Recurse -Force } '@ $scriptPath = "C:\Scripts\AutoBackup_DGReadiness.ps1" New-Item -ItemType Directory -Path (Split-Path $scriptPath ) -Force | Out-Null $backupScript | Out-File -FilePath $scriptPath -Encoding UTF8Write-Host "自动备份脚本已创建: $scriptPath " -ForegroundColor Green$action = New-ScheduledTaskAction -Execute "PowerShell.exe" -Argument "-NoProfile -ExecutionPolicy Bypass -File `"$scriptPath `"" $trigger = New-ScheduledTaskTrigger -Daily -At "02:00" $settings = New-ScheduledTaskSettingsSet -StartWhenAvailable -DontStopOnIdleEnd $principal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -LogonType ServiceAccount -RunLevel HighestRegister-ScheduledTask -TaskName "AutoBackup DGReadiness" -Action $action -Trigger $trigger -Settings $settings -Principal $Principal -Force Write-Host "计划任务已创建:AutoBackup DGReadiness" -ForegroundColor GreenWrite-Host "执行时间:每天凌晨02:00" -ForegroundColor Yellow
常见问题解答 错误代码与问题解决方案 问题1:执行策略错误 错误信息:
无法加载文件 DG_Readiness_Tool_v3.6.ps1,因为在此系统上禁止运行脚本。 有关详细信息,请参阅 https:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies。
错误代码: 无特定错误代码原因: PowerShell执行策略限制解决方案:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass -Force Write-Host "✓ 执行策略已临时设置为Bypass" -ForegroundColor GreenWrite-Host "当前执行策略: $ (Get-ExecutionPolicy -Scope Process)" -ForegroundColor Cyan.\DG_Readiness_Tool_v3.6 .ps1 -Disable -HVCI
永久解决方案:
Get-ExecutionPolicy -List Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned -Force Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted -Force
问题2:权限不足错误 错误信息:
访问路径 'C:\Windows\System32\drivers\' 被拒绝。 或 您需要管理员权限才能运行此脚本。
错误代码: ERROR_ACCESS_DENIED (5)原因: 缺少管理员权限解决方案:
if (!([Security.Principal.WindowsPrincipal ][Security.Principal.WindowsIdentity ]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole ] "Administrator" )) { Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath `"" -Verb RunAs exit } $currentUser = [Security.Principal.WindowsIdentity ]::GetCurrent()$principal = New-Object Security.Principal.WindowsPrincipal($currentUser )$isAdmin = $principal .IsInRole([Security.Principal.WindowsBuiltInRole ]::Administrator)if (-not $isAdmin ) { Write-Host "✗ 需要管理员权限" -ForegroundColor Red Write-Host "请右键点击PowerShell,选择'以管理员身份运行'" -ForegroundColor Yellow exit } else { Write-Host "✓ 已获得管理员权限" -ForegroundColor Green }
问题3:工具无法找到 错误信息:
术语 'DG_Readiness_Tool_v3.6.ps1' 无法被识别为 cmdlet、函数、脚本文件或可运行程序的名称。
错误代码: ERROR_FILE_NOT_FOUND (2)原因: 脚本文件不存在或路径错误解决方案:
$toolPath = "C:\Tools\dgreadiness_v3.6\DG_Readiness_Tool_v3.6.ps1" if (Test-Path $toolPath ) { Write-Host "✓ 工具脚本存在" -ForegroundColor Green } else { Write-Host "✗ 工具脚本不存在" -ForegroundColor Red Write-Host "请检查路径是否正确" -ForegroundColor Yellow Write-Host "`n正在搜索工具脚本..." -ForegroundColor Cyan $possiblePaths = @ ( "$env:USERPROFILE \Downloads\dgreadiness_v3.6" , "C:\Tools\dgreadiness_v3.6" , "D:\Tools\dgreadiness_v3.6" ) foreach ($path in $possiblePaths ) { if (Test-Path $path ) { Write-Host "找到目录: $path " -ForegroundColor Green $files = Get-ChildItem -Path $path -Filter "*.ps1" foreach ($file in $files ) { Write-Host " - $ ($file .Name)" -ForegroundColor Gray } } } } if (Test-Path $toolPath ) { Set-Location (Split-Path $toolPath ) .\DG_Readiness_Tool_v3.6 .ps1 -Disable -HVCI }
问题4:VBS无法禁用 错误信息:
禁用操作完成后,重启系统,msinfo32仍显示"基于虚拟化的安全性:正在运行"
错误代码: 无特定错误代码原因: 可能的原因包括:
Windows Hello VBS隐藏依赖(Windows 11 24H2/25H2)
组策略强制启用
UEFI锁未解除
注册表配置未完全清理
解决方案:
Write-Host "开始完整清理VBS配置..." -ForegroundColor CyanWrite-Host "`n[1/6] 禁用Windows Hello VBS..." -ForegroundColor Cyan$windowsHelloPath = "HKLM:\SYSTEM\CurrentControlSet\Control\DeviceGuard\Scenarios\WindowsHello" if (Test-Path $windowsHelloPath ) { Set-ItemProperty -Path $windowsHelloPath -Name "Enabled" -Value 0 -Type DWord -Force Write-Host " ✓ Windows Hello VBS已禁用" -ForegroundColor Green } else { Write-Host " - Windows Hello VBS路径不存在" -ForegroundColor Gray } Write-Host "`n[2/6] 清理Device Guard注册表..." -ForegroundColor Cyan$deviceGuardPath = "HKLM:\SYSTEM\CurrentControlSet\Control\DeviceGuard" if (Test-Path $deviceGuardPath ) { Set-ItemProperty -Path $deviceGuardPath -Name "EnableVirtualizationBasedSecurity" -Value 0 -Type DWord -Force Set-ItemProperty -Path $deviceGuardPath -Name "RequirePlatformSecurityFeatures" -Value 0 -Type DWord -Force $scenarios = @ ("HypervisorEnforcedCodeIntegrity" , "WindowsHello" , "DeviceGuard" ) foreach ($scenario in $scenarios ) { $scenarioPath = "$deviceGuardPath \Scenarios\$scenario " if (Test-Path $scenarioPath ) { Set-ItemProperty -Path $scenarioPath -Name "Enabled" -Value 0 -Type DWord -Force Write-Host " ✓ 已禁用: $scenario " -ForegroundColor Green } } } Write-Host "`n[3/6] 清理LSA配置..." -ForegroundColor Cyan$lsaPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa" if (Test-Path $lsaPath ) { Remove-ItemProperty -Path $lsaPath -Name "LsaCfgFlags" -ErrorAction SilentlyContinue Set-ItemProperty -Path $lsaPath -Name "LsaCfgFlags" -Value 0 -Type DWord -ErrorAction SilentlyContinue Write-Host " ✓ LSA配置已清理" -ForegroundColor Green } Write-Host "`n[4/6] 修改BCD配置..." -ForegroundColor Cyanbcdedit /set hypervisorlaunchtype off bcdedit /set vsmlaunchtype off bcdedit /set `{current`} hypervisorlaunchtype off bcdedit /set `{current`} vsmlaunchtype off Write-Host " ✓ BCD配置已修改" -ForegroundColor GreenWrite-Host "`n[5/6] 禁用Windows功能..." -ForegroundColor Cyan$featuresToDisable = @ ( "Microsoft-Hyper-V-All" , "Microsoft-Hyper-V" , "HypervisorPlatform" , "VirtualMachinePlatform" , "Containers-DisposableClientVM" , "Windows-Defender-ApplicationGuard" ) foreach ($feature in $featuresToDisable ) { $state = Get-WindowsOptionalFeature -Online -FeatureName $feature -ErrorAction SilentlyContinue if ($state -and $state .State -eq "Enabled" ) { Disable-WindowsOptionalFeature -Online -FeatureName $feature -NoRestart Write-Host " ✓ 已禁用: $feature " -ForegroundColor Green } } Write-Host "`n[6/6] 使用dgreadiness工具确认..." -ForegroundColor Cyan$dgToolPath = "C:\Tools\dgreadiness_v3.6\DG_Readiness_Tool_v3.6.ps1" if (Test-Path $dgToolPath ) { Set-Location (Split-Path $dgToolPath ) .\DG_Readiness_Tool_v3.6 .ps1 -Disable Write-Host " ✓ dgreadiness工具已执行" -ForegroundColor Green } Write-Host "`n================================" -ForegroundColor GrayWrite-Host "配置清理完成!" -ForegroundColor GreenWrite-Host "请立即重启系统" -ForegroundColor YellowWrite-Host "重启后如出现SecConfig菜单,请按F3确认禁用" -ForegroundColor Yellow
处理UEFI锁:
$deviceGuardPath = "HKLM:\SYSTEM\CurrentControlSet\Control\DeviceGuard" $locked = (Get-ItemProperty -Path $deviceGuardPath -ErrorAction SilentlyContinue).Lockedif ($locked -eq 1 ) { Write-Host "检测到UEFI锁" -ForegroundColor Yellow Write-Host "需要在BIOS/UEFI中手动禁用以下选项:" -ForegroundColor Cyan Write-Host "1. Virtualization Based Security (VBS)" -ForegroundColor White Write-Host "2. Secure Boot" -ForegroundColor White Write-Host "3. Intel SGX / AMD PSP" -ForegroundColor White Write-Host "" Write-Host "具体步骤:" -ForegroundColor Cyan Write-Host "1. 重启电脑" -ForegroundColor White Write-Host "2. 进入BIOS/UEFI设置(通常按F2、Del、F10等)" -ForegroundColor White Write-Host "3. 找到Security或Advanced选项" -ForegroundColor White Write-Host "4. 禁用VBS相关选项" -ForegroundColor White Write-Host "5. 保存并退出" -ForegroundColor White Write-Host "6. 重新运行此脚本" -ForegroundColor White }
问题5:重启后蓝屏 错误信息:
系统重启后出现蓝屏(BSOD) 错误代码:CRITICAL_PROCESS_DIED 或 SYSTEM_SERVICE_EXCEPTION
错误代码:
CRITICAL_PROCESS_DIED (0xEF)
SYSTEM_SERVICE_EXCEPTION (0x3B)
原因: VBS驱动冲突或系统文件损坏解决方案:
Write-Host "系统蓝屏修复方案:" -ForegroundColor CyanWrite-Host "================================" -ForegroundColor GrayWrite-Host "步骤1:进入安全模式" -ForegroundColor YellowWrite-Host " - 强制关机3次,进入Windows恢复环境" -ForegroundColor WhiteWrite-Host " - 选择'高级选项' → '启动设置' → '重启'" -ForegroundColor WhiteWrite-Host " - 按4或F4进入安全模式" -ForegroundColor WhiteWrite-Host "" Write-Host "步骤2:运行修复命令" -ForegroundColor YellowWrite-Host " 在安全模式下打开PowerShell(管理员),执行:" -ForegroundColor WhiteWrite-Host "" Write-Host " # 禁用VBS" -ForegroundColor GrayWrite-Host " bcdedit /set hypervisorlaunchtype off" -ForegroundColor CyanWrite-Host " bcdedit /set vsmlaunchtype off" -ForegroundColor CyanWrite-Host "" Write-Host " # 修复系统文件" -ForegroundColor GrayWrite-Host " sfc /scannow" -ForegroundColor CyanWrite-Host "" Write-Host " # 修复映像" -ForegroundColor GrayWrite-Host " DISM /Online /Cleanup-Image /RestoreHealth" -ForegroundColor CyanWrite-Host "" Write-Host " # 恢复注册表" -ForegroundColor GrayWrite-Host " reg import C:\DGReadiness_Backup_*.reg" -ForegroundColor CyanWrite-Host "" Write-Host "步骤3:正常重启" -ForegroundColor YellowWrite-Host " 重启系统,看是否正常启动" -ForegroundColor WhiteWrite-Host "" Write-Host "步骤4:使用系统还原" -ForegroundColor YellowWrite-Host " 如果仍然蓝屏,使用系统还原点恢复" -ForegroundColor WhiteWrite-Host " 或使用'重置此电脑'功能" -ForegroundColor White
自动化修复脚本:
Write-Host "开始系统修复..." -ForegroundColor CyanWrite-Host "[1/4] 修复系统文件..." -ForegroundColor Cyansfc /scannow Write-Host "[2/4] 修复Windows映像..." -ForegroundColor CyanDISM /Online /Cleanup-Image /CheckHealth DISM /Online /Cleanup-Image /ScanHealth DISM /Online /Cleanup-Image /RestoreHealth Write-Host "[3/4] 修复BCD配置..." -ForegroundColor Cyanbcdedit /set hypervisorlaunchtype off bcdedit /set vsmlaunchtype off bcdedit /set {default} safeboot minimal Write-Host "[4/4] 恢复默认注册表配置..." -ForegroundColor Cyan$deviceGuardPath = "HKLM:\SYSTEM\CurrentControlSet\Control\DeviceGuard" if (Test-Path $deviceGuardPath ) { Set-ItemProperty -Path $deviceGuardPath -Name "EnableVirtualizationBasedSecurity" -Value 0 -Type DWord -Force Set-ItemProperty -Path $deviceGuardPath -Name "RequirePlatformSecurityFeatures" -Value 0 -Type DWord -Force } Write-Host "修复完成!重启系统" -ForegroundColor GreenWrite-Host "重启后按F8进入启动菜单,选择'正常启动'" -ForegroundColor Yellow
问题6:虚拟化软件仍无法使用 错误信息:
VMware/VirtualBox仍显示"检测到Hypervisor"或VT-x不可用
错误代码: VMware: VMware unrecoverable error原因: Hypervisor未完全卸载解决方案:
Write-Host "完全移除Hyper-V和Hypervisor..." -ForegroundColor CyanWrite-Host "`n[1/4] 禁用Hyper-V功能..." -ForegroundColor Cyan$hyperVFeatures = @ ( "Microsoft-Hyper-V" , "Microsoft-Hyper-V-Management-PowerShell" , "Microsoft-Hyper-V-Management-Clients" , "Microsoft-Hyper-V-Tools" , "Microsoft-Hyper-V-Hypervisor" , "HypervisorPlatform" , "VirtualMachinePlatform" ) foreach ($feature in $hyperVFeatures ) { $state = Get-WindowsOptionalFeature -Online -FeatureName $feature -ErrorAction SilentlyContinue if ($state -and $state .State -eq "Enabled" ) { Write-Host " 禁用: $feature " -ForegroundColor Yellow Disable-WindowsOptionalFeature -Online -FeatureName $feature -NoRestart -ErrorAction SilentlyContinue } } Write-Host "`n[2/4] 修改BCD配置..." -ForegroundColor Cyanbcdedit /set hypervisorlaunchtype off bcdedit /set vsmlaunchtype off bcdedit /set `{current`} isolatedcontext No Write-Host " ✓ BCD已修改" -ForegroundColor GreenWrite-Host "`n[3/4] 停止相关服务..." -ForegroundColor Cyan$hvServices = @ ("hvboot" , "HvHost" , "vmms" )foreach ($service in $hvServices ) { $svc = Get-Service -Name $service -ErrorAction SilentlyContinue if ($svc ) { Write-Host " 停止: $service " -ForegroundColor Yellow Stop-Service -Name $service -Force -ErrorAction SilentlyContinue Set-Service -Name $service -StartupType Disabled -ErrorAction SilentlyContinue } } Write-Host "`n[4/4] 验证Hypervisor状态..." -ForegroundColor Cyan$hypervisor = Get-CimInstance -ClassName Win32_ComputerSystem | Select-Object HypervisorPresentif ($hypervisor .HypervisorPresent) { Write-Host " ✗ Hypervisor仍存在" -ForegroundColor Red Write-Host " 需要重启系统" -ForegroundColor Yellow } else { Write-Host " ✓ Hypervisor已移除" -ForegroundColor Green } Write-Host "`n请立即重启系统" -ForegroundColor Yellow
深度清理(最后手段):
Write-Host "深度清理Hypervisor组件..." -ForegroundColor CyanWrite-Host "⚠️ 警告:此操作将删除所有Hyper-V相关组件" -ForegroundColor RedWrite-Host " 包括Windows Sandbox、WSL2等功能" -ForegroundColor Red$confirmation = Read-Host "确认继续?(Y/N)" if ($confirmation -ne 'Y' -and $confirmation -ne 'y' ) { exit } Write-Host "`n[1/5] 删除Hypervisor服务..." -ForegroundColor Cyan$services = @ ("hvboot" , "HvHost" , "vmms" , "vmcompute" )foreach ($serviceName in $services ) { $service = Get-WmiObject -Class Win32_Service -Filter "Name='$serviceName '" -ErrorAction SilentlyContinue if ($service ) { Write-Host " 删除: $serviceName " -ForegroundColor Yellow $service .StopService() $service .Delete() } } Write-Host "`n[2/5] 删除Hypervisor驱动..." -ForegroundColor Cyan$drivers = @ ("hvservice.sys" , "hvboot.sys" )foreach ($driver in $drivers ) { $driverPath = "$env:SystemRoot \System32\drivers\$driver " if (Test-Path $driverPath ) { Write-Host " 删除: $driver " -ForegroundColor Yellow Rename-Item -Path $driverPath -NewName "$driver .bak" -Force } } Write-Host "`n[3/5] 清理注册表..." -ForegroundColor Cyan$regPaths = @ ( "HKLM:\SYSTEM\CurrentControlSet\Services\hvboot" , "HKLM:\SYSTEM\CurrentControlSet\Services\HvHost" , "HKLM:\SYSTEM\CurrentControlSet\Control\DeviceGuard" ) foreach ($path in $regPaths ) { if (Test-Path $path ) { Write-Host " 清理: $path " -ForegroundColor Yellow Remove-Item -Path $path -Recurse -Force -ErrorAction SilentlyContinue } } Write-Host "`n[4/5] 重置BCD..." -ForegroundColor Cyanbcdedit /deletevalue {current} isolatedcontext bcdedit /deletevalue {bootmgr} isolatedcontext bcdedit /set hypervisorlaunchtype off bcdedit /set vsmlaunchtype off Write-Host "`n[5/5] 最终验证..." -ForegroundColor Cyan$hypervisor = Get-CimInstance -ClassName Win32_ComputerSystem | Select-Object HypervisorPresentif ($hypervisor .HypervisorPresent) { Write-Host " ⚠️ Hypervisor仍存在,可能需要重启多次" -ForegroundColor Yellow } else { Write-Host " ✓ Hypervisor已完全移除" -ForegroundColor Green } Write-Host "`n请立即重启系统" -ForegroundColor YellowWrite-Host "如仍有问题,可能需要重新安装系统" -ForegroundColor Red
问题7:工具下载失败 错误信息:
从Microsoft下载页面下载失败,或下载的文件损坏
错误代码: ERROR_INTERNET_CANNOT_CONNECT原因: 网络问题或官方链接失效解决方案:
Write-Host "dgreadiness工具多源下载方案" -ForegroundColor CyanWrite-Host "================================" -ForegroundColor GrayWrite-Host "`n源1:Microsoft官方下载页" -ForegroundColor GreenWrite-Host "URL: https://www.microsoft.com/en-us/download/details.aspx?id=53337" -ForegroundColor WhiteWrite-Host "步骤:" -ForegroundColor YellowWrite-Host " 1. 访问上述URL" -ForegroundColor WhiteWrite-Host " 2. 选择语言" -ForegroundColor WhiteWrite-Host " 3. 点击Download按钮" -ForegroundColor WhiteWrite-Host " 4. 下载dgreadiness_v3.6.zip" -ForegroundColor WhiteWrite-Host "`n源2:PowerShell直接下载" -ForegroundColor Green$directUrls = @ ( "https://download.microsoft.com/download/6/4/1/641C3FAF-2C49-45D6-8E8A-C8FD93B2F7C3/dgreadiness_v3.6.zip" , "https://aka.ms/deviceguardreadiness" ) foreach ($url in $directUrls ) { Write-Host "尝试下载: $url " -ForegroundColor Yellow $outputPath = "$env:USERPROFILE \Downloads\dgreadiness_v3.6.zip" try { $webClient = New-Object System.Net.WebClient $webClient .DownloadFile($url , $outputPath ) if (Test-Path $outputPath ) { $fileInfo = Get-Item $outputPath Write-Host " ✓ 下载成功: $ ($fileInfo .Length) 字节" -ForegroundColor Green break } } catch { Write-Host " ✗ 下载失败: $_ " -ForegroundColor Red } } Write-Host "`n源3:从另一台电脑复制" -ForegroundColor GreenWrite-Host "步骤:" -ForegroundColor YellowWrite-Host " 1. 在另一台可访问的电脑上下载工具" -ForegroundColor WhiteWrite-Host " 2. 通过U盘或网络共享复制到目标电脑" -ForegroundColor WhiteWrite-Host " 3. 解压到C:\Tools\dgreadiness_v3.6" -ForegroundColor WhiteWrite-Host "`n源4:使用备用下载工具" -ForegroundColor GreenWrite-Host "可以使用以下工具下载:" -ForegroundColor YellowWrite-Host " - Internet Explorer / Edge浏览器" -ForegroundColor WhiteWrite-Host " - Firefox / Chrome浏览器" -ForegroundColor WhiteWrite-Host " - 下载管理器(如Free Download Manager)" -ForegroundColor WhiteWrite-Host "`n验证下载的文件..." -ForegroundColor Cyan$downloadedFile = "$env:USERPROFILE \Downloads\dgreadiness_v3.6.zip" if (Test-Path $downloadedFile ) { $fileInfo = Get-Item $downloadedFile Write-Host "文件信息:" -ForegroundColor Yellow Write-Host " 大小: $ ($fileInfo .Length) 字节" -ForegroundColor White Write-Host " 修改时间: $ ($fileInfo .LastWriteTime)" -ForegroundColor White if ($fileInfo .Length -gt 30000 -and $fileInfo .Length -lt 50000 ) { Write-Host " ✓ 文件大小正常" -ForegroundColor Green } else { Write-Host " ✗ 文件大小异常,可能损坏" -ForegroundColor Red } Write-Host "`n测试解压..." -ForegroundColor Cyan $testDir = "$env:TEMP \dgreadiness_test" try { Expand-Archive -Path $downloadedFile -DestinationPath $testDir -Force Write-Host " ✓ 文件可以正常解压" -ForegroundColor Green $scriptFile = "$testDir \DG_Readiness_Tool_v3.6.ps1" if (Test-Path $scriptFile ) { Write-Host " ✓ 主脚本文件存在" -ForegroundColor Green } Remove-Item -Path $testDir -Recurse -Force } catch { Write-Host " ✗ 解压失败: $_ " -ForegroundColor Red } } else { Write-Host "✗ 下载的文件不存在" -ForegroundColor Red }
问题8:Windows Hello问题 错误信息:
禁用VBS后,Windows Hello无法使用,提示"需要重新设置PIN"
错误代码: 无特定错误代码原因: Windows Hello依赖VBS的安全隔离功能解决方案:
Write-Host "Windows Hello重新配置方案" -ForegroundColor CyanWrite-Host "================================" -ForegroundColor GrayWrite-Host "问题说明:" -ForegroundColor YellowWrite-Host "Windows Hello的某些功能(如人脸识别、指纹)依赖VBS" -ForegroundColor WhiteWrite-Host "禁用VBS后,这些功能将无法使用" -ForegroundColor WhiteWrite-Host "" Write-Host "解决方案1:重新设置PIN(推荐)" -ForegroundColor GreenWrite-Host "1. 打开设置 → 账户 → 登录选项" -ForegroundColor WhiteWrite-Host "2. 找到Windows Hello PIN" -ForegroundColor WhiteWrite-Host "3. 点击'我忘记了我的PIN'" -ForegroundColor WhiteWrite-Host "4. 按提示重新设置PIN" -ForegroundColor WhiteWrite-Host "" Write-Host "解决方案2:使用密码登录" -ForegroundColor GreenWrite-Host "1. 打开设置 → 账户 → 登录选项" -ForegroundColor WhiteWrite-Host "2. 点击'添加'设置密码" -ForegroundColor WhiteWrite-Host "3. 在登录界面使用密码代替PIN" -ForegroundColor WhiteWrite-Host "" Write-Host "解决方案3:禁用Windows Hello(不推荐)" -ForegroundColor GreenWrite-Host "1. 打开设置 → 账户 → 登录选项" -ForegroundColor WhiteWrite-Host "2. 移除Windows Hello相关选项" -ForegroundColor WhiteWrite-Host "3. 仅使用密码登录" -ForegroundColor WhiteWrite-Host "" Write-Host "注意:" -ForegroundColor YellowWrite-Host "如果需要使用Windows Hello的高级功能," -ForegroundColor WhiteWrite-Host "需要重新启用VBS或使用支持VBS的Windows版本(如Enterprise版)" -ForegroundColor White
检查Windows Hello兼容性:
Write-Host "检查Windows Hello兼容性..." -ForegroundColor Cyan$vbsStatus = Get-CimInstance -ClassName Win32_DeviceGuard -Namespace root\Microsoft\Windows\DeviceGuardWrite-Host "VBS状态: $ ($vbsStatus .VirtualizationBasedSecurityStatus)" -ForegroundColor $ (if ($vbsStatus .VirtualizationBasedSecurityStatus -eq 0 ) { "Yellow" } else { "Green" })$windowsHelloPath = "HKLM:\SYSTEM\CurrentControlSet\Control\DeviceGuard\Scenarios\WindowsHello" if (Test-Path $windowsHelloPath ) { $helloEnabled = (Get-ItemProperty -Path $windowsHelloPath ).Enabled Write-Host "Windows Hello VBS: $helloEnabled " -ForegroundColor $ (if ($helloEnabled -eq 1 ) { "Green" } else { "Yellow" }) } Write-Host "`n可用的Windows Hello功能:" -ForegroundColor Cyan$helloCapabilities = Get-CimInstance -ClassName Win32_BiometricFeature -ErrorAction SilentlyContinueif ($helloCapabilities ) { $helloCapabilities | Select-Object BiometricType, Description | Format-Table } else { Write-Host " 未检测到生物识别设备" -ForegroundColor Gray } Write-Host "`n建议:" -ForegroundColor Yellowif ($vbsStatus .VirtualizationBasedSecurityStatus -eq 0 ) { Write-Host " - VBS已禁用,Windows Hello高级功能可能受限" -ForegroundColor White Write-Host " - PIN登录仍可正常使用" -ForegroundColor White Write-Host " - 人脸识别、指纹等功能可能无法使用" -ForegroundColor White Write-Host " - 如需这些功能,请重新启用VBS" -ForegroundColor White } else { Write-Host " - VBS已启用,Windows Hello应可正常工作" -ForegroundColor White }
操作失败排查清单 当使用dgreadiness工具关闭VBS功能失败时,按以下清单逐一排查:
Write-Host "dgreadiness操作失败排查清单" -ForegroundColor CyanWrite-Host "================================" -ForegroundColor Gray$issues = @ ()$currentUser = [Security.Principal.WindowsIdentity ]::GetCurrent()$principal = New-Object Security.Principal.WindowsPrincipal($currentUser )$isAdmin = $principal .IsInRole([Security.Principal.WindowsBuiltInRole ]::Administrator)if (-not $isAdmin ) { $issues += @ { Item = "管理员权限" Status = "❌ 失败" Solution = "右键PowerShell,选择'以管理员身份运行'" } } else { $issues += @ { Item = "管理员权限" Status = "✓ 通过" Solution = "" } } $executionPolicy = Get-ExecutionPolicy -Scope Process if ($executionPolicy -eq "Restricted" ) { $issues += @ { Item = "执行策略" Status = "❌ 失败" Solution = "运行: Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass" } } else { $issues += @ { Item = "执行策略" Status = "✓ 通过" Solution = "" } } $toolPath = "C:\Tools\dgreadiness_v3.6\DG_Readiness_Tool_v3.6.ps1" if (-not (Test-Path $toolPath )) { $issues += @ { Item = "工具文件" Status = "❌ 失败" Solution = "确认文件路径正确,或重新下载工具" } } else { $issues += @ { Item = "工具文件" Status = "✓ 通过" Solution = "" } } $osVersion = [int ](Get-CimInstance Win32_OperatingSystem).BuildNumberif ($osVersion -lt 14393 ) { $issues += @ { Item = "系统版本" Status = "❌ 失败" Solution = "需要Windows 10 1607或更新版本" } } else { $issues += @ { Item = "系统版本" Status = "✓ 通过" Solution = "" } } if ($osVersion -ge 26100 ) { $windowsHelloPath = "HKLM:\SYSTEM\CurrentControlSet\Control\DeviceGuard\Scenarios\WindowsHello" if (Test-Path $windowsHelloPath ) { $helloEnabled = (Get-ItemProperty -Path $windowsHelloPath ).Enabled if ($helloEnabled -eq 1 ) { $issues += @ { Item = "Windows Hello VBS" Status = "⚠️ 警告" Solution = "需要禁用Windows Hello VBS:Set-ItemProperty -Path '$windowsHelloPath ' -Name 'Enabled' -Value 0" } } } } $deviceGuardPath = "HKLM:\SYSTEM\CurrentControlSet\Control\DeviceGuard" $locked = (Get-ItemProperty -Path $deviceGuardPath -ErrorAction SilentlyContinue).Lockedif ($locked -eq 1 ) { $issues += @ { Item = "UEFI锁" Status = "❌ 失败" Solution = "在BIOS/UEFI中禁用VBS相关选项" } } $policyPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DeviceGuard" if (Test-Path $policyPath ) { $policyEnabled = (Get-ItemProperty -Path $policyPath -ErrorAction SilentlyContinue).EnableDeviceGuard if ($policyEnabled -eq 1 ) { $issues += @ { Item = "组策略" Status = "⚠️ 警告" Solution = "通过gpedit.msc禁用Device Guard组策略" } } } Write-Host "`n检查结果:" -ForegroundColor CyanWrite-Host "================================" -ForegroundColor Gray$hasIssues = $false foreach ($issue in $issues ) { Write-Host "[$ ($issue .Item)] $ ($issue .Status)" -ForegroundColor $ (if ($issue .Status -match "✓" ) { "Green" } elseif ($issue .Status -match "⚠️" ) { "Yellow" } else { "Red" }) if ($issue .Solution) { Write-Host " 解决方案: $ ($issue .Solution)" -ForegroundColor Gray $hasIssues = $true } } if ($hasIssues ) { Write-Host "`n建议:解决上述问题后重试" -ForegroundColor Yellow } else { Write-Host "`n✓ 所有检查通过,可以继续操作" -ForegroundColor Green }
日志文件分析 dgreadiness工具执行后会生成日志文件,可用于问题诊断:
Write-Host "dgreadiness日志文件分析" -ForegroundColor CyanWrite-Host "================================" -ForegroundColor Gray$logDir = "C:\DGLogs" if (Test-Path $logDir ) { $logFiles = Get-ChildItem -Path $logDir -Filter "*.log" | Sort-Object LastWriteTime -Descending if ($logFiles .Count -gt 0 ) { $latestLog = $logFiles [0 ] Write-Host "最新日志文件: $ ($latestLog .Name)" -ForegroundColor Green Write-Host "创建时间: $ ($latestLog .LastWriteTime)" -ForegroundColor Yellow Write-Host "文件大小: $ ([math]::Round($latestLog .Length / 1KB, 2)) KB" -ForegroundColor Yellow Write-Host "" Write-Host "日志内容分析:" -ForegroundColor Cyan Write-Host "================================" -ForegroundColor Gray $logContent = Get-Content $latestLog .FullName -Raw $errors = [regex ]::Matches($logContent , "Error|Failed|Exception|警告" ) if ($errors .Count -gt 0 ) { Write-Host "`n发现 $ ($errors .Count) 个错误/警告:" -ForegroundColor Red $logLines = Get-Content $latestLog .FullName foreach ($line in $logLines ) { if ($line -match "Error|Failed|Exception|警告" ) { Write-Host " $line " -ForegroundColor Red } } } else { Write-Host "`n✓ 未发现错误信息" -ForegroundColor Green } Write-Host "`n关键操作:" -ForegroundColor Cyan $keyOperations = @ ("Disable" , "Enable" , "HVCI" , "VBS" , "Device Guard" , "Credential Guard" ) foreach ($op in $keyOperations ) { if ($logContent -match $op ) { Write-Host " - $op " -ForegroundColor White } } Write-Host "`n日志最后50行:" -ForegroundColor Cyan Get-Content $latestLog .FullName | Select-Object -Last 50 | ForEach-Object { $color = "White" if ($_ -match "Error|Failed|Exception" ) { $color = "Red" } elseif ($_ -match "Success|Complete|Done" ) { $color = "Green" } elseif ($_ -match "Warning|警告" ) { $color = "Yellow" } Write-Host $_ -ForegroundColor $color } $analysisPath = "$logDir \Analysis_$ (Get-Date -Format 'yyyyMMdd_HHmmss').txt" $logContent | Out-File -FilePath $analysisPath Write-Host "`n日志已保存到: $analysisPath " -ForegroundColor Green } else { Write-Host "未找到日志文件" -ForegroundColor Yellow } } else { Write-Host "日志目录不存在: $logDir " -ForegroundColor Yellow Write-Host "请先运行dgreadiness工具" -ForegroundColor Yellow }
技术支持资源 官方文档资源
社区支持资源
紧急联系方式 如果遇到严重问题导致系统无法启动:
使用Windows恢复环境
重启3次进入恢复环境
选择”疑难解答” → “高级选项”
使用”系统还原”或”启动修复”
联系Microsoft支持
寻求专业技术支持
IT管理员
认证技术专家
Microsoft合作伙伴
常见应用场景
场景
是否需要禁用VBS
替代方案
VMware/VirtualBox使用
✅ 是
暂无完美替代方案
驱动兼容性问题
✅ 是
更新驱动程序
性能优化
⚠️ 视情况
通常不需要
特定软件要求
✅ 是
联系软件供应商
安全测试
✅ 是
测试完成后重新启用
快速参考命令 Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass -Force Set-Location "C:\Tools\dgreadiness_v3.6" .\DG_Readiness_Tool_v3.6 .ps1 -Disable -AutoReboot Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass -Force Set-Location "C:\Tools\dgreadiness_v3.6" .\DG_Readiness_Tool_v3.6 .ps1 -Disable -HVCI -AutoReboot Get-CimInstance -ClassName Win32_DeviceGuard -Namespace root\Microsoft\Windows\DeviceGuard | Select-Object VirtualizationBasedSecurityStatus, SecurityServicesRunning Get-CimInstance -ClassName Win32_ComputerSystem | Select-Object HypervisorPresent.\DG_Readiness_Tool_v3.6 .ps1 -Enable -AutoReboot
重要提醒 ⚠️ 安全警告
禁用VBS会显著降低系统安全性
仅在必要时执行此操作
操作完成后加强其他安全措施
完成任务后建议重新启用
⚠️ 功能影响
Windows Sandbox将无法使用
WSL2可能受影响
某些Windows Hello功能受限
Credential Guard保护失效
⚠️ 操作建议
操作前务必备份
在测试环境先验证
记录所有配置更改
准备恢复方案
附录 A. 相关技术术语表
术语
英文全称
中文说明
VBS
Virtualization-Based Security
基于虚拟化的安全
HVCI
Hypervisor-Enforced Code Integrity
Hypervisor强制代码完整性
HVCI
Memory Integrity
内存完整性(用户界面名称)
DG
Device Guard
设备防护
CG
Credential Guard
凭据保护
VSM
Virtual Secure Mode
虚拟安全模式
UEFI
Unified Extensible Firmware Interface
统一可扩展固件接口
SLAT
Second Level Address Translation
二级地址转换
TPM
Trusted Platform Module
可信平台模块
CI
Code Integrity
代码完整性
BCD
Boot Configuration Data
启动配置数据
B. 系统要求对照表
组件
Windows 10
Windows 11
Windows Server
最低版本
1607
21H2
2016
推荐版本
21H2+
23H2+
2019+
内存(最低)
4GB
4GB
4GB
内存(推荐)
8GB+
8GB+
8GB+
TPM
1.2+
2.0+
2.0+
CPU
64位VT-x/AMD-V
64位VT-x/AMD-V
64位VT-x/AMD-V
SLAT
必需
必需
必需
C. 错误代码速查表
错误代码
错误名称
常见原因
解决方案
0x80070005
ERROR_ACCESS_DENIED
权限不足
以管理员身份运行
0x80070002
ERROR_FILE_NOT_FOUND
文件不存在
检查路径
0x80070490
ERROR_NOT_FOUND
元素未找到
检查驱动兼容性
0x80092004
CRYPT_E_NOT_FOUND
证书未找到
检查Secure Boot
0xC0000022
STATUS_ACCESS_DENIED
访问被拒绝
检查权限和策略
0x000000EF
CRITICAL_PROCESS_DIED
关键进程终止
系统修复或还原
D. PowerShell命令速查 Get-CimInstance -ClassName Win32_DeviceGuard -Namespace root\Microsoft\Windows\DeviceGuardGet-CimInstance -ClassName Win32_ComputerSystem | Select-Object HypervisorPresentSet-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass([Security.Principal.WindowsPrincipal ][Security.Principal.WindowsIdentity ]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole ]::Administrator) Checkpoint-Computer -Description "Before VBS Disable" -RestorePointType "MODIFY_SETTINGS" bcdedit /enum # 修改BCD bcdedit /set hypervisorlaunchtype off bcdedit /set vsmlaunchtype off # 禁用Windows 功能 Disable -WindowsOptionalFeature -Online -FeatureName "Microsoft -Hyper -V -All " -NoRestart # 查看Windows 功能 Get -WindowsOptionalFeature -Online | Where -Object { $_ .State -eq "Enabled" }Get-Service -Name hvboot, HvHost, vmmssysteminfo msinfo32 Get-WinEvent -FilterHashtable @ {LogName='System' ; Level=2 } -MaxEvents 10 Get-CimInstance -ClassName Win32_PnPSignedDriver
E. 常用路径和文件位置 dgreadiness工具: - 默认位置: C:\Tools\dgreadiness_v3.6\ - 主脚本: DG_Readiness_Tool_v3.6.ps1 - 日志目录: C:\DGLogs\ 注册表路径: - Device Guard: HKLM\SYSTEM\CurrentControlSet\Control\DeviceGuard - LSA: HKLM\SYSTEM\CurrentControlSet\Control\Lsa - 组策略: HKLM\SOFTWARE\Policies\Microsoft\Windows\Device Guard 系统文件: - Hyper-V驱动: C:\Windows\System32\drivers\hv*.sys - SecConfig.efi: EFI分区\EFI\Microsoft\Boot\SecConfig.efi 日志文件: - 系统日志: C:\Windows\Logs\ - 事件查看器: 事件查看器 → Windows 日志
文档版本: 1.0最后更新: 2026年3月21日适用系统: Windows 10 1607+, Windows 11, Windows Server 2016+工具版本: dgreadiness v3.6
本站点文档仅供技术参考,操作前请确保已充分理解相关风险并做好备份工作。如有疑问,请咨询专业技术人员。