LoginSignup
1
2

More than 5 years have passed since last update.

PowerShellでBitLockerのHDD暗号化が有効かどうかを確認する

Last updated at Posted at 2015-09-23

Windows標準で使えるHDD暗号化機能BitLockerの暗号化状態を取得してチェックする処理をPowerShellで書いたので貼っておく。

BitLockerの暗号化状態はWMI経由で root/CIMV2/Security/MicrosoftVolumeEncryptionProtectionStatus から取得できる。
以下のサンプルではCドライブに絞り込んでるけど、WHEREを付けなければ全部のドライブが取得できる。

function Check-VolumeEnc{
    $volumeEnc = @{}
    # Cドライブ以外のドライブが存在する場合もあるが、環境依存のためCドライブの暗号化状態のみチェックする
    $volume = Get-WMIObject -Namespace "root/CIMV2/Security/MicrosoftVolumeEncryption" -Query "SELECT * FROM Win32_EncryptableVolume WHERE DriveLetter='C:'"
    # BitLockerの暗号化状態
    $volumeEnc["ProtectionStatus"] = $volume.ProtectionStatus
    $statusMsg = ""
    switch ($volume.ProtectionStatus) {
        0 { $statusMsg = 'decrypted' }
        1 { $statusMsg = 'encrypted' }
        default { $statusMsg = "unknown status($($volume.ProtectionStatus))" }
    }
    $volumeEnc["ProtectionStatusMsg"] = $statusMsg

    # チェック判定
    if ($volume.ProtectionStatus -eq 1) {
        $volumeEnc["CheckStatus"] = "OK"
    } else {
        $volumeEnc["CheckStatus"] = "NG"
    }

    return $volumeEnc
}
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2