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

All managed objects

February 18, 2021 Views: 2548

The script emails a list of Active Directory objects managed by the user that the script is executed on. This includes all objects that have the user specified either in the Manager or in the Managed By attribute.

To be able to create such a report on request, you will need to create a custom command that executes the script on User objects.


  • $to - Specifies the recipient(s) of the report.
  • $subject - Specifies the subject of the e-mail message.
  • $reportHeader - Specifies the email message header (in HTML format).
  • $reportFooter - Specifies the email message footer (in HTML format).
Edit Remove
# Email message settings
$to = "recipient@domain.com" # TODO: modify me
$subject = "My Subject" # TODO: modify me
$reportHeader = "<h1><b>Objects Managed by %name%</b></h1><br/>" # TODO: modify me
$reportFooter = "<hr /><p><i>Please do not reply to this e-mail, it has been sent to you for notification purposes only.</i></p>" # TODO: modify me

# Get the default Web Interface address
$webInterfaceAddress = "%adm-WebInterfaceUrl%"
if ([System.String]::IsNullOrEmpty($webInterfaceAddress))
    $Context.LogMessage("Default web interface address not set for Adaxes service. For details, see http://www.adaxes.com/help/?HowDoI.ManageService.RegisterWebInterface.html", "Warning")

# Get all direct reports
    $directReports = $Context.TargetObject.GetEx("directReports")
    $directReports = $NULL
    $subordinates = "The user doesn't have any direct reports.<br />"

# Get names of all the direct reports and add them to the report
if ($directReports -ne $NULL)
    $subordinates = "<b>Direct Reports:</b><br /><ol>"
    foreach ($directReport in $directReports)
        # Bind to user
        $user = $Context.BindToObjectByDN($directReport)
        # Get username and GUID
        $username = [Softerra.Adaxes.Utils.ObjectNameHelper]::GetObjectName($user, 'IncludeParentPath')
        $userGuid = [Guid] $user.Get("ObjectGuid")
        # Add to report
        $subordinates += "<li><a href='$webInterfaceAddress`ViewObject.aspx?guid=$userGuid'>$username</a></li>"
    $subordinates += "</ol>"

# Get all managed objects
    $managedObjectDNs = $Context.TargetObject.Get("managedObjects")
    $managedObjectDNs = $NULL
    $managedObjects = "The user doesn't have any managed objects."

# Get names of all managed objects and add them to the report
if ($managedObjectDNs -ne $NULL)
    $managedObjects = "<b>Managed objects:</b><br /><ol>"
    foreach ($managedObjectDN in $managedObjectDNs)
        # Bind to object
        $object = $Context.BindToObjectByDN($managedObjectDN)
        # Get object name and GUID
        $objectName = [Softerra.Adaxes.Utils.ObjectNameHelper]::GetObjectName($object, 'IncludeParentPath')
        $objectGuid = [Guid] $object.Get("ObjectGuid")
        # Add to report
        $managedObjects += "<li><a href='$webInterfaceAddress`ViewObject.aspx?guid=$objectGuid'>$objectName</a></li>"
    $managedObjects += "</ol>"

# Build the report
$report = $reportHeader + $subordinates + $managedObjects + $reportFooter

# Send mail
$Context.SendMail($to, $subject, $NULL, $report)

Comments 2
Grant Mar 23, 2023
Note, if you're using Adaxes 2023 or higher you'll need to change these parts of the script for the links to function correctly otherwise you'll get a 404 error clicking on the links.
Change "ViewObject.aspx?guid=$userGuid" to "Admin#/Browse/$userGuid" on line 39
Change "ViewObject.aspx?guid=$objectGuid" to "Admin#/Browse/$objectGuid" on line 70
Support Mar 24, 2023
Hello Grant,

Thank you for pointing this out. You are absolutely right about the changes required for the script to work in Adaxes 2023.
Leave a comment

Got questions?

Support Questions & Answers