Reputation: 67
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
Upvotes: 1
Views: 3843
Reputation: 1059
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.
Upvotes: 1