通过 Powershell 进行 BitLocker 加密 - BitLocker 等待激活

时间:2021-04-21 21:29:35

标签: windows powershell encryption activation 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 密钥处于“待处理”状态。

感谢任何帮助,真的很想知道如何从中制作一个有效的脚本。

谢谢!

0 个答案:

没有答案
相关问题