0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Bitlocker メモ

Posted at

# Cドライブを指定してBitLockerを有効化するコマンドを実行する
$enableBitLockerCommand = "Enable-BitLocker -MountPoint 'C:' -RecoveryPasswordProtector -UsedSpaceOnly -SkipHardwareTest"
$returnValue = Invoke-Expression $enableBitLockerCommand

# 戻り値が0であるかどうかを確認する
if ($returnValue -eq 0) {
  # 回復キーをDドライブに格納するコマンドを実行する
  $storeRecoveryKeyCommand = "Protect-BitLocker -MountPoint 'C:' -RecoveryPassword $(Get-BitLockerVolume -MountPoint 'C:' -Type RecoveryPassword).RecoveryPassword -RecoveryKeyPath 'D:\BitLockerRecoveryKey.txt'"
  $returnValue = Invoke-Expression $storeRecoveryKeyCommand

  # 戻り値が0であるかどうかを確認する
  if ($returnValue -eq 0) {
    Write-Host "BitLocker has been enabled and the recovery key has been stored successfully."
  } else {
    # 戻り値が1である場合、失敗をログに記録して異常終了する
    Write-Host "Failed to store the BitLocker recovery key."
    # ここにログに失敗を記録するコードを追加します
    exit 1
  }
} else {
  # 戻り値が1である場合、失敗をログに記録して異常終了する
  Write-Host "Failed to enable BitLocker on the C drive."
  # ここにログに失敗を記録するコードを追加します
  exit 1
}

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?