首页 > 解决方案 > 通过 Powershell 进行 BitLocker 加密 - BitLocker 等待激活

问题描述

我正在尝试使用 Powershell 在我们所有的设备上启用 BitLocker。我们没有 AD 环境,大多数计算机也没有外部存储密钥的地方。然而,一旦启用加密,我们的 RMM 服务确实有办法托管密钥。

这是我正在使用的 Powershell 脚本:

#Check BitLocker prerequisites
$TPMNotEnabled = Get-WmiObject win32_tpm -Namespace root\cimv2\security\microsofttpm | where {$_.IsEnabled_InitialValue -eq $false} -ErrorAction SilentlyContinue
$TPMEnabled = Get-WmiObject win32_tpm -Namespace root\cimv2\security\microsofttpm | where {$_.IsEnabled_InitialValue -eq $true} -ErrorAction SilentlyContinue
$WindowsVer = Get-WmiObject -Query 'select * from Win32_OperatingSystem where (Version like "6.2%" or Version like "6.3%" or Version like "10.0%") and ProductType = "1"' -ErrorAction SilentlyContinue
$BitLockerReadyDrive = Get-BitLockerVolume -MountPoint $env:SystemDrive -ErrorAction SilentlyContinue
$BitLockerDecrypted = Get-BitLockerVolume -MountPoint $env:SystemDrive | where {$_.VolumeStatus -eq "FullyDecrypted"} -ErrorAction SilentlyContinue


#Step 1 - Check if TPM is enabled and initialise if required
if ($WindowsVer -and !$TPMNotEnabled) 
{
Initialize-Tpm -AllowClear -AllowPhysicalPresence -ErrorAction SilentlyContinue
}

#Step 2 - Check if BitLocker volume is provisioned and partition system drive for BitLocker if required
if ($WindowsVer -and $TPMEnabled -and !$BitLockerReadyDrive) 
{
Get-Service -Name defragsvc -ErrorAction SilentlyContinue | Set-Service -Status Running -ErrorAction SilentlyContinue
BdeHdCfg -target $env:SystemDrive shrink -quiet
}

#Step 3 - If all prerequisites are met, then enable BitLocker
if ($WindowsVer -and $TPMEnabled -and $BitLockerReadyDrive -and $BitLockerDecrypted) 
{
Add-BitLockerKeyProtector -MountPoint $env:SystemDrive -TpmProtector
Enable-BitLocker -MountPoint C: -SkipHardwareTest -RecoveryKeyPath "'$env:UserProfile'\Desktop\BitlLocker_Recovery_Key.txt" -RecoveryKeyProtector -ErrorAction SilentlyContinue
}


(Get-BitLockerVolume -MountPoint C).KeyProtector > "$env:UserProfile\Desktop\BitLocker_Recovery_Key.txt"

当我在设备上运行脚本时,.txt 文件被放置在桌面上,没有任何内容,并且在 BitLocker 设置中,它被设置为“BitLocker 等待激活”状态。

磁盘管理中的驱动器也表明驱动器已加密,但我没有密钥,并且我们的 RMM 显示我们的 BitLocker 密钥的“待定”状态。

任何帮助表示赞赏,真的想知道如何制作一个工作脚本。

谢谢!

标签: windowspowershellencryptionactivationbitlocker

解决方案


推荐阅读