是否有简单的方法可以解锁 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:
用您的 Bitlocked 卷替换。
确保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