
是否可以透過簡單的方式解鎖 Bitlocker 加密磁碟機?
在命令列中我會使用類似的東西:
manage-bde -unlock -pw d:
然後輸入密碼。但對於 powershell 來說,到目前為止我得到的最好的結果是這樣的:
Unlock-Bitlocker -MountPoint x: -Password (ConvertTo-Securestring "MyPassword" -AsPlainText -Force)
我不想將我的密碼轉換為安全字串,我只想手動輸入它,我知道 mange-bde 也可以在 powershell 上運行,但我想知道是否有一種 powershell 方法可以以簡單的方式做到這一點?
答案1
$key = Read-Host 'Password!' -AsSecureString; Unlock-Bitlocker x: -Password $key >$nul
替換x:
為您的位元鎖定磁碟區。
確保Runas Admin
我將此功能用於Auto Lock-Unlock
我的 Bitlocked 驅動器
#lock-unlock.ps1
function Bit {
GetAdmin
Clear-Host
$Drive = (BitlockerVolume | ? {$_.KeyProtector -like "Password"}).MountPoint
if ( !$Drive ) {'No Bitlocked Volume on This PC'; pause; exit 0}
$line = '------------------------'
if ( test-path $Drive ) {
"Volume `"$($Drive)`" Unlocked"; 'Lock it now ?'
$line
$ans = Read-Host "(Enter) Yes (AnyKey) Exit"
if ( $ans ) { exit 0 }
Lock-Bitlocker $Drive >$nul
} else {
"Volume `"$($Drive)`" Locked"; 'Unlock it now ?'
$line
$key = Read-Host 'Password!' -AsSecureString
if ( $key.length -ge 8 ) {
Unlock-Bitlocker $Drive -Password $key >$nul
# Replace to your path if want to open dir
#explorer "$($Drive)\#HF5-files"
}
}
Bit
}
function GetAdmin {
if ( $(fltmc).count -eq 3 ) {
$arg = "-NoProfile", "-ExecutionPolicy Bypass", "-File `"$PSCommandPath`""
Start -Verb RunAs powershell.exe -ArgumentList $arg; exit 0
}
}
####
Bit