We use cookies to improve your experience.
By your continued use of this site you accept such use.
For more details please see our privacy policy and cookies policy.

Script repository

Computers with BitLocker status

August 05, 2024 Views: 6110

The script generates a report containing computers and their Bitlocker status. To execute the script, create a report with the corresponding custom column. A scope is required for the report.

In the script, the $columnID varialbe specifies the identifier of the Boolean custom column that will contain Biltocker statuses. To get the identifier of a custom column:

  1. In the Report-specific columns section, on the Columns tab, right-click the custom column.
  2. In the context menu, navigate to Copy and click Column ID.
  3. The column identifier will be copied to clipboard.
Edit Remove
PowerShell
$columnID = "{a72d4285-3013-42f0-b22b-5a942908ac1b}" # TODO: modify me

$bitlockerSearcher = New-Object Softerra.Adaxes.Adsi.Search.DirectorySearcher $NULL, $False
$bitlockerSearcher.VirtualRoot = $True
$bitlockerSearcher.SearchParameters.ReferralChasing = "ADS_CHASE_REFERRALS_NEVER"
$criteria = New-AdmCriteria msFVE-RecoveryInformation
$bitlockerSearcher.SearchParameters.Criteria = $criteria
$bitlockerSearcher.SearchParameters.PageSize = 500

$computerDNsWithBitlocker = New-Object "System.Collections.Generic.HashSet[System.String]"
try
{
    $bitlockerIterator = $bitlockerSearcher.ExecuteSearch()
    while ($Context.MoveNext($bitlockerIterator))
    {
        $bitlockerSearchResult = $bitlockerIterator.Current
        $dn = New-Object "Softerra.Adaxes.Ldap.DN" $bitlockerSearchResult.AdsPath.DN
        $computerDNsWithBitlocker.Add($dn.Parent)
    }
}
finally
{
    if ($bitlockerIterator) { $bitlockerIterator.Dispose() }
}

$criteria = New-AdmCriteria computer
$Context.DirectorySearcher.AddCriteria($criteria)
try
{
    $searchIterator = $Context.DirectorySearcher.ExecuteSearch()
    while ($Context.MoveNext($searchIterator))
    {
        $searchResult = $searchIterator.Current
        $containsBitlocker = $computerDNsWithBitlocker.Contains($searchResult.AdsPath.DN)
        $Context.Items.Add($searchResult, @{ $columnID = $containsBitlocker }, $NULL)
    }
}
finally
{
    if ($searchIterator) { $searchIterator.Dispose() }
}
Comments 0
Leave a comment
Loading...

Got questions?

Support Questions & Answers