Script Repository

Objects located in multiple OUs

February 15, 2022

The script generates a report containing objects located in the OUs selected in a report parameter. Objects are added to the report based on a search filter. For information on creating reports, see the Create Report tutorial.


  • $ousParam - Specifies the name of the object picker parameter used to select the OUs to search in. The name should be specified with the param- prefix.
  • $ousParamSeparator - Specifies the separator defined for the parameter values.
  • $searchFilter - Specifies the LDAP search filter used to find objects to be included into the report.
Edit Remove
$ousParam = "param-searchOUs" # TODO: modify me
$ousParamSeparator = ";" # TODO: modify me
$searchFilter = "(objectCategory=computer)" # TODO: modify me

# Get parameter value
$ouDNs = $Context.GetParameterValue($ousParam)

# Specify search filter

foreach ($dn in $ouDNs.Split($ousParamSeparator))
    # Add items to the report
    $Context.DirectorySearcher.BaseObjectPath = $dn

Comments ( 0 )
No results found.
Leave a comment