我们有配备 TPM 芯片的 Windows 7 Enterprise 笔记本电脑。我们已将 Bitlocker 部署到这些笔记本电脑上。我想要完成的是编写一个 PowerShell 脚本来查找 AD 中特定计算机的 msTPM-OwnerInformation 值。我希望它采用该值并重置 TPMLockout。
现在我们必须进入 TPM 控制台并单击重置并指定包含该值的 XML 文件。
我已经开始编写一个脚本,但由于我对 PowerShell 非常陌生,所以它并没有按照我的意愿去做。
我们有配备 TPM 芯片的 Windows 7 Enterprise 笔记本电脑。我们已将 Bitlocker 部署到这些笔记本电脑上。我想要完成的是编写一个 PowerShell 脚本来查找 AD 中特定计算机的 msTPM-OwnerInformation 值。我希望它采用该值并重置 TPMLockout。
现在我们必须进入 TPM 控制台并单击重置并指定包含该值的 XML 文件。
我已经开始编写一个脚本,但由于我对 PowerShell 非常陌生,所以它并没有按照我的意愿去做。
创建一个名为“Get_msTPM-OwnerInformation.ps1”的新文件并将以下文本粘贴到其中。
根据您的需要更改“域/OU”部分。这应该会从 AD 中读取您需要的所有信息
#----------------------Start----------------------------------------------------------------
#Custom variables
$CsvFilePath = "C:\Temp\BitLockerComputerReport.csv"
#Create array to hold computer information
$export = @()
#Export computers not Bitlocker-enabled to a CSV-file
#$BitLockerEnabled = Get-QADObject -SizeLimit 0 -IncludedProperties cn,Name,ParentContainer,msFVE-RecoveryPassword | Where-Object {$_.type -eq “msFVE-RecoveryInformation”} | Foreach-Object {
$BitLockerEnabled = Get-QADObject -SearchRoot 'DOMAIN/OU' -SizeLimit 0 -IncludedProperties cn,Name,ParentContainer,msFVE-RecoveryPassword | Where-Object {$_.type -eq “msFVE-RecoveryInformation”} | Foreach-Object {
#Get PasswordID
$_.cn -match “(?<={).*(?=})"
#Create custom object for each computer
$computerobj = New-Object -TypeName psobject
#Add information to custom object
$computerobj | Add-Member -MemberType NoteProperty -Name Name -Value (Split-Path -Path $_.ParentContainer -Leaf)
$computerobj | Add-Member -MemberType NoteProperty -Name PasswordID -Value $matches[0]
$computerobj | Add-Member -MemberType NoteProperty -Name "msFVE-RecoveryPassword" -Value $_."msFVE-RecoveryPassword"
$computerobj | Add-Member -MemberType NoteProperty -Name "msTPM-OwnerInformation" -Value (Get-QADComputer -IncludedProperties "msTPM-OwnerInformation" -Name (Split-Path -Path $_.ParentContainer -Leaf))."msTPM-OwnerInformation"
$export += $computerobj
}
#Export the array with computerinformation to the user-specified path
$export | Export-Csv -Path $CsvFilePath -NoTypeInformation
#------------------------End--------------------------------------------------------------