I need to scan the Bitlocker status in a relatively large environment and would like the output in a structured CSV file. This is what I have so far, but it seems to be hanging when executed.
$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
Any guidance here will be appreciated