I'm trying to encrypt an external drive via powershell with bitlocker.
The script i'm posting here will be part of a bigger setup where all attached disks to a pc will be automaticly formatted and then have bitlocker enabled on them. I'm trying to set a password for unlocking the volume and export a recovery key incase worst case scenario passes...
the code:
$Pass = 'xxxxx.' | ConvertTo-SecureString -AsPlainText -Force
Enable-BitLocker -MountPoint "E:" -EncryptionMethod Aes256 -UsedSpaceOnly -PasswordProtector -Password $Pass
Add-BitLockerKeyProtector -MountPoint "E:" -RecoveryKeyPath "D:\keys\" -RecoveryKeyProtector
do
{
$Volume = Get-BitLockerVolume -MountPoint E:
Write-Progress -Activity "Encrypting volume $($Volume.MountPoint)" -Status "Encryption Progress:" -PercentComplete $Volume.EncryptionPercentage
Start-Sleep -Seconds 1
}
until ($Volume.VolumeStatus -eq 'FullyEncrypted')
Write-Progress -Activity "Encrypting volume $($Volume.MountPoint)" -Status "Encryption Progress:" -Completed
I'm getting an error : parameter set cannot be resolved using the specified named parameters.
Isn't it possible to both use the password and recoverykey action when bitlocking?
Thanks in advance
You cannot use both a password and recovery key when calling Enable-BitLocker
.
From TechNet : "You can specify only one of these methods or combinations when you enable encryption, but you can use the Add-BitLockerKeyProtector cmdlet to add other protectors."
So use Add-BitLockerKeyProtector
after enabling.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.