Powershell – How to input password to manage-bde -pw option via windows powershell

bitlockerdisk-encryptionpowershellwindows-command-prompt

I am trying to encrypt Data volume (for example E:) with the following command:

manage-bde -protectors -add E: -pw

When I execute the above command, it will ask for the password, so I entered it. It is successfully encrypting my data volume. Now, I want to make a script to encrypt a data volume, so I need to pass the password as an argument to the above powershell command.

How can I do that? Is there any option of passing the password for manage-bde command?

Best Answer

If you're working on Windows Server 2012 or newer, you can use the BitLocker cmdlets:

Add-BitLockerKeyProtector -MountPoint "E:" -Password ("Password" | ConvertTo-SecureString -AsPlainText -Force) -PasswordProtector

The Add-BitLockerKeyProtector cmdlet accepts the password in the form of a SecureString object, which is why we pipe the plaintext "Password" to ConvertTo-SecureString