从AD检索Bitlocker恢复密钥

时间:2018-05-18 12:38:22

标签: powershell bitlocker

Powershell相当新,我设法获得以下代码来检索域中计算机的Bitlocker密钥,但是,我有一个问题:

Clear-Host
$TestOU = "OU=ABC,DC=XYZ,DC=com"
$PCs = Get-ADComputer -Filter * -SearchBase $TestOU
$Results = ForEach ($Computer in $PCs)
{
New-Object PSObject -Property @{
ComputerName = $Computer.Name
RecoveryPassword = Get-ADObject -Filter 'objectclass -eq "msFVE- 
RecoveryInformation"' -SearchBase $computer.DistinguishedName -Properties 
msFVE-RecoveryPassword,whencreated | sort whencreated -Descending | select 
msfve-recoverypassword
}
}
$Results

我的每个密码的输出都以{a {msfve-recoverypassword =开头,我不知道如何删除它。

1 个答案:

答案 0 :(得分:0)

以下代码提供了有用的输出,供用户在shell中使用,但也可以在脚本中使用:

$computer = Get-ADComputer $computerName
Get-ADObject -Filter 'objectClass -eq "msFVE-RecoveryInformation"' -SearchBase $computer.DistinguishedName -Properties whenCreated, msFVE-RecoveryPassword | `
  Sort whenCreated -Descending | Select whenCreated, msFVE-RecoveryPassword