4

I have written bitlocker code to backup key after old key has been shared with user.

My requirement is that don't want to display WARNING: ACTIONS REQUIRED: while running script

enter image description here

$BLV = Get-BitLockerVolume -MountPoint "C:"
$KeyProt = $BLV.KeyProtector | Where-object{$_.KeyProtectorType -eq "RecoveryPassword"}
$KeyProt.KeyProtectorId
Remove-BitlockerKeyProtector -MountPoint "C:" -KeyProtectorId $KeyProt.KeyProtectorId
Add-BitLockerKeyProtector -MountPoint "C:" -RecoveryPasswordProtector
$BLV = Get-BitLockerVolume -MountPoint "C:"
$KeyProt = $BLV.KeyProtector | Where-object{$_.KeyProtectorType -eq "RecoveryPassword"}
$KeyProt.KeyProtectorId
Backup-BitLockerKeyProtector -MountPoint "C:" -KeyProtectorId $KeyProt.KeyProtectorId
Resume-BitLocker -MountPoint "C:"
Suraj Kumar
  • 159
  • 3
  • 10

1 Answers1

3

Windows PowerShell has many more streams than Linux.

Here's the list from Microsoft's about_Redirection:

enter image description here

You may redirect all streams using the wildcard *>$null. You may also use a file instead of $null.

Reference : Redirecting output to $null in PowerShell, but ensuring the variable remains set.


An alternative is to add to the Add-BitLockerKeyProtector command the parameter -ErrorVariable out to store the error message in variable out.

Or if this isn't an error message, perhaps -InformationVariable out.

For more information see about_CommonParameters.

harrymc
  • 498,455