I copied a default report "objects in OU", so i think it is generated by the following script
# Get parameter values
$objectTypes = $Context.GetParameterValue("param-ObjectTypes")
$scope = $Context.GetParameterValue("param-Scope")
$subtreeScope = $scope -eq "ADS_SCOPE_SUBTREE"
# Custom column identifiers
$ouColumnID = "{44db2afb-5559-4d2f-a1f7-e623e3a6c815}"
# Create a searcher for child objects
$childObjSearcher = New-Object Softerra.Adaxes.Adsi.Search.DirectorySearcher $NULL, $False
$childObjSearcher.SearchParameters.SearchScope = $scope
$childObjSearcher.SearchParameters.ReferralChasing = "ADS_CHASE_REFERRALS_NEVER"
$childObjSearcher.SearchParameters.Filter = "(|" + $objectTypes + ")"
$childObjSearcher.SearchParameters.PageSize = 500
$childObjSearcher.SetPropertiesToLoad($Context.DirectorySearcher.GetPropertiesToLoad())
# Add properties necessary to generate the report
$propertiesForOUs = @("objectClass", "objectGuid", "distinguishedName")
$Context.DirectorySearcher.SetPropertiesToLoad($propertiesForOUs)
# Search filter
$filter = "(objectCategory=organizationalUnit)"
$Context.DirectorySearcher.AppendFilter($filter)
# Generate report
try
{
$searchIterator = $Context.DirectorySearcher.ExecuteSearch()
while ($Context.MoveNext($searchIterator))
{
$searchResult = $searchIterator.Current
$ouDN = $searchResult.GetPropertyByName("distinguishedName").Values[0]
$columnValues = @{ $ouColumnID = $ouDN; }
# Search for child objects
$hasChildObjects = $False
$childObjSearcher.SearchParameters.BaseObjectPath = $searchResult.AdsPath
try
{
$childObjSearchIterator = $childObjSearcher.ExecuteSearch()
while ($Context.MoveNext($childObjSearchIterator))
{
$childObjSearchResult = $childObjSearchIterator.Current
if ($subtreeScope -and ($childObjSearchResult.AdsPath -eq $searchResult.AdsPath))
{
# Subtree scope includes the base object. We don't need the object in the report.
continue
}
$hasChildObjects = $True
# Add the object to the report
$Context.Items.Add($childObjSearchResult, $columnValues, $NULL)
}
}
finally
{
if ($childObjSearchIterator) { $childObjSearchIterator.Dispose() }
}
if ($hasChildObjects -eq $False)
{
# The OU is empty
if ($styleNoChildObjects -eq $NULL)
{
$styleNoChildObjects = $Context.Items.CreateItemStyle("#3d3d3d", $NULL,
"ADM_LISTITEMFONTSTYLE_REGULAR")
}
$Context.Items.Add(-1, "<Keine Objekte>", "Information", $columnValues, $styleNoChildObjects)
}
}
}
finally
{
if ($searchIterator) { $searchIterator.Dispose() }
}