以下是一个示例的PowerShell脚本,用于在Windows上启用BitLocker:

# 检查是否支持BitLocker
$drive = "C:"
if ((Get-WmiObject -Namespace "ROOT\CIMv2\Security\MicrosoftVolumeEncryption" -Query "SELECT * FROM Win32_EncryptableVolume WHERE DriveLetter = '$drive'").ProtectionStatus -ne 0) {
    Write-Host "该驱动器已启用BitLocker。"
    exit
}

# 检查是否存在TPM芯片
$tpmStatus = Get-WmiObject -Namespace "ROOT\CIMv2\Security\MicrosoftTpm" -Class Win32_Tpm | Select-Object -ExpandProperty SpecVersion
if ($tpmStatus -eq $null) {
    Write-Host "该计算机没有TPM芯片。无法启用BitLocker。"
    exit
}

# 请求BitLocker密码
$password = Read-Host -Prompt "请输入BitLocker密码" -AsSecureString

# 启用BitLocker
$encryptionMethod = "aes256"
$securePassword = ConvertTo-SecureString -String $password -AsPlainText -Force
$protector = Get-WmiObject -Namespace "ROOT\CIMv2\Security\MicrosoftVolumeEncryption" -Query "SELECT * FROM Win32_EncryptableVolume WHERE DriveLetter = '$drive'" | Get-BitLockerVolume
$protector.ProtectWithPassword($securePassword, $encryptionMethod)

Write-Host "BitLocker已成功启用!"

请注意,这个脚本假设要启用BitLocker的驱动器为C:驱动器。如果要启用其他驱动器,请将$drive变量设置为相应的驱动器字母

windows 开启bitlocker powershell脚本

原文地址: https://www.cveoy.top/t/topic/ilCs 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录