我需要在相对较大的环境中扫描 Bitlocker 状态,并希望以结构化 CSV 文件的形式输出。这是我到目前为止所拥有的,但在执行时它似乎挂起。
$Computers = Get-Content -Path "C:\script\allComputers.txt"
$bdeObject = @()
foreach ($computer in $Computers) {
$bde = manage-bde -cn $computer -status C:
$Name = $bde | Select-String "Computer Name:"
$Name = ($ComputerName -split ": ")[1]
$Status = $bde | Select-String "Conversion Status:"
$Status = ($ConversionStatus -split ": ")[1]
$Status = $ConversionStatus -replace '\s',''
$Encrypted = $bde | Select-String "Percentage Encrypted:"
$Encrypted = ($PercentageEncrypted -split ": ")[1]
$Method = $bde | Select-String "Encryption Method:"
$Method = ($Method -split ": ")[1]
$Version = $bde | Select-String "Bitlocker Version:"
$Version = ($Version -split ": ")[1]
$Size = $bde | Select-String "Size:"
$Size = ($Size -split ": ")[1]
#Add all fields to an array that contains custom formatted objects with desired fields
$bdeObject += New-Object psobject -Property @{'Computer Name'=$Name; 'Conversion Status'=$Status; 'Percentage Encrypted'=$Encrypted; 'Encryption Method'=$Method; 'Bitlocker Version'=$Version; 'Size'=$Size;}
}
$bdeObject | Export-CSV C:\script\output.csv -Append -NoTypeInformation
这里的任何指导将不胜感激