Skip to content

Instantly share code, notes, and snippets.

@ak9999
Created February 7, 2020 13:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ak9999/c7eb441f4116623cadc878922e292431 to your computer and use it in GitHub Desktop.
Save ak9999/c7eb441f4116623cadc878922e292431 to your computer and use it in GitHub Desktop.
# Generate Report of BitLocker Status for Computers in the BitLocker Machines OU.
param([string]$OutputDirectory="~/Desktop",[string]$OrganizationalUnit=([adsi]'').distinguishedName)
if(!([Security.Principal.WindowsPrincipal] `
[Security.Principal.WindowsIdentity]::GetCurrent() `
).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Write-Host -ForegroundColor Yellow "Only Administrators can read BitLocker Recovery Keys."
exit
}
$computers = Get-ADComputer -Filter * -SearchBase $OrganizationalUnit
$results = ForEach ($computer in $computers) {
New-Object PSObject -Property @{
ComputerName = $computer.Name
RecoveryInformation = Get-ADObject -Filter {objectclass -eq 'msFVE-RecoveryInformation'} -SearchBase $computer.DistinguishedName -Properties 'msFVE-RecoveryPassword'
}
}
if(!(Test-Path -Path $OutputDirectory)) {
New-Item -ItemType Directory -Path $OutputDirectory
}
$results | Export-Csv -Path "$OutputDirectory\bitlocker-report-$(Get-Date -format "yyyyMMdd-HHmm").csv" -NoTypeInformation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment