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

Objects located in multiple OUs

February 15, 2022 Views: 570

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
Leave a comment

Got questions?

Support Questions & Answers