2016-02-29 232 views
1

我正試圖自動執行此過程。通過運行下面的命令,我可以獲得我正在尋找的信息。數值密碼ID是ID:{DFB478E6-8B3F-4DCA-9576-C1905B49C71E}自動化如何在AD中備份Bitlocker恢復信息的過程

管理bde -protectors -get C:

我需要再取該值{DFB478E6- 8B3F-4DCA-9576-C1905B49C71E}並使用不同的語法將其放在相同的命令中。

manage-bde -protectors -adbackup c: -id {DFB478E6-8B3F-4DCA-9576-C1905B49C71E} 

問題是我需要從命令提示符下程序提供的信息中去掉它。

我需要編寫腳本,以便將其導入到MDT 2013任務序列中。任何方向將不勝感激。

這將在我成像時在本地機器上運行。完整的輸出如下。

manage-bde -protectors -get c: 

Example: 

Bitlocker Drive Encryption: Configuration Tool version 6.1.7600 
Copyright (C) Microsoft Corporation. All rights reserved. 
Volume C: Old Win7 
All Key Protectors 
External Key: 
    ID: {F12ADB2E-22D5-4420-980C-851407E9EB30} 
    External Key File Name: 
    F12ADB2E-22D5-4420-980C-851407E9EB30.BEK 

Numerical Password: 
    ID: {DFB478E6-8B3F-4DCA-9576-C1905B49C71E} 
    Password: 
    224631-534171-438834-445973-130867-430507-680922-709896 

TPM And PIN: 
    ID: {EBAFC4D6-D044-4AFB-84E3-26E435067AA5} 

回答

1

爲什麼不使用專用的CmdLet。從提升的Windows PowerShell控制檯,使用Get-BitlockerVolume功能,選擇-MountPoint C,並選擇KeyProtector屬性:

(Get-BitLockerVolume -MountPoint C).KeyProtector 

所有Bitlocker能的cmdlet:

get-command -Noun *bitlocker* 

CommandType  Name            Version Source 
-----------  ----            ------- ------ 
Function  Add-BitLockerKeyProtector       1.0.0.0 BitLocker 
Function  Backup-BitLockerKeyProtector      1.0.0.0 BitLocker 
Function  Clear-BitLockerAutoUnlock       1.0.0.0 BitLocker 
Function  Disable-BitLocker         1.0.0.0 BitLocker 
Function  Disable-BitLockerAutoUnlock      1.0.0.0 BitLocker 
Function  Enable-BitLocker         1.0.0.0 BitLocker 
Function  Enable-BitLockerAutoUnlock       1.0.0.0 BitLocker 
Function  Get-BitLockerVolume        1.0.0.0 BitLocker 
Function  Lock-BitLocker          1.0.0.0 BitLocker 
Function  Remove-BitLockerKeyProtector      1.0.0.0 BitLocker 
Function  Resume-BitLocker         1.0.0.0 BitLocker 
Function  Suspend-BitLocker         1.0.0.0 BitLocker 
Function  Unlock-BitLocker         1.0.0.0 BitLocker 

因此,如果返回的文本是原始文本字符串,你可以這樣做:

$text = & manage-bde -protectors -get c: 
$reg = [regex]'.*(\{.*?\}).*' 
$a = $reg.Matches($text) 

所以你走了牛逼的3 UUID

$a[0].captures.groups[1].value 
$a[1].captures.groups[1].value 
$a[2].captures.groups[1].value 

如果返回的文本是一個多行文本字符串,你可以這樣做:

$text = & manage-bde -protectors -get c: 
$text = $text | Out-String 
$reg = [regex]'.*(\{.*?\}).*' 
$a = $reg.Matches($text) 

所以,你有你的3 UUID

$a[0].captures.groups[1].value 
$a[1].captures.groups[1].value 
$a[2].captures.groups[1].value 
+0

謝謝爲信息@JP,但這些是隻運行PowerShell v2.0 – NobleMan

+0

@ Ken的Windows 7機器,我嘗試使用正則表達式來調整我的答案。 – JPBlanc

+0

@JP再次感謝您的輸入!當我運行三個$ a [1] ...命令中的任何一個時,它告訴我它們是空的。我究竟做錯了什麼? – NobleMan