無法連續執行enable-bitlocker和lock-bitlocker

無法連續執行enable-bitlocker和lock-bitlocker

我正在嘗試使用以下命令在 Windows Server 2012 R2 資料磁碟區上啟用 Bitlocker:

Enable-BitLocker -MountPoint $volume -Password ($password | ConvertTo-SecureString -AsPlainText -Force) -PasswordProtector

之後我嘗試鎖定資料量,

Lock-BitLocker $volume -ForceDismount

現在,這裡的問題是,加密過程被擱置,因為我已經鎖定了資料卷。我想在全卷加密後鎖定資料卷。加密過程完成後是否有任何選項可以鎖定資料卷?有什麼幫助嗎?

答案1

這裡,看起來您可以用來Get-BitLocker尋找驅動器的狀態以及加密進度:

PS C:\> Get-BitLockerVolume 
VolumeType      Mount CapacityGB VolumeStatus           Encryption KeyProtector              AutoUnlock Protection
                Point                                   Percentage                           Enabled    Status
----------      ----- ---------- ------------           ---------- ------------              ---------- ----------
Data            D:        931.51 EncryptionInProgress   1          {RecoveryPassword, Pas...            Off

您可以在呼叫之前添加一些類似的程式碼Lock-BitLocker,以每隔幾秒鐘檢查加密是否完成:

do {
    Start-Sleep -Seconds 10
    $drive = Get-BitLocker -MountPoint $volume
} while ($drive.VolumeStatus -in @('FullyDecrypted','EncryptionInProgress'))

(我還沒有測試過這段程式碼。也許你可以檢查 VolumeStatus 是否為「FullyEncrypted」(如果結果就是這樣的話)。

相關內容