Powershell: Wie entsperrt man ein mit Bitlocker verschlüsseltes Laufwerk einfach?

Powershell: Wie entsperrt man ein mit Bitlocker verschlüsseltes Laufwerk einfach?

Ist es möglich, ein mit Bitlocker verschlüsseltes Laufwerk auf einfache Weise zu entsperren?

In der Befehlszeile würde ich etwas wie Folgendes verwenden:

manage-bde -unlock -pw d:

und geben Sie anschließend das Passwort ein. Für Powershell ist das Beste, was ich bisher bekommen habe, so etwas wie das hier:

Unlock-Bitlocker -MountPoint x: -Password (ConvertTo-Securestring "MyPassword" -AsPlainText -Force)

Ich möchte mein Kennwort nicht in eine sichere Zeichenfolge umwandeln, sondern es manuell eingeben. Ich weiß, dass mange-bde auch mit Powershell funktioniert, aber ich frage mich, ob es eine einfache Möglichkeit mit Powershell gibt.

Antwort1

$key = Read-Host 'Password!' -AsSecureString; Unlock-Bitlocker x: -Password $key >$nul

Ersetzen Sie es x:durch Ihr BitLocker-Volume.

stellen Sie sicherRunas Admin


Ich verwende diese Funktion für Auto Lock-Unlockmein Bitlocked-Laufwerk

#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

Antwort2

Sie können das folgende Powershell-Skript verwenden, um zur Eingabe eines Kennworts aufzufordern, es sicher einzugeben und dann den Rest Ihres Skripts auszuführen.

$UserCredential = Get-Credential -Message "Enter a password" -UserName "not applicable"

Unlock-Bitlocker -MountPoint x: -Password $UserCredential.Password

Das Ergebnis sieht ungefähr so ​​aus:

Bildbeschreibung hier eingeben

verwandte Informationen