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: 768

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.

Parameters:

  • $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
PowerShell
$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
$Context.DirectorySearcher.AppendFilter($searchFilter)

foreach ($dn in $ouDNs.Split($ousParamSeparator))
{
    # Add items to the report
    $Context.DirectorySearcher.BaseObjectPath = $dn
    $Context.Items.Add($Context.DirectorySearcher)    
}
Comments 0
Leave a comment
Loading...

Got questions?

Support Questions & Answers