The Activity Scope shows nothing. I included the text as it appears in our script.
$to = "eca@aspendental.com" # TODO: modify me
$subject = "Adaxes Alert - group membership" # TODO: modify me
$reportHeader = "<b>Group membership</b><br/><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
function SearchObjects($filter, $properties)
{
$searcher = $Context.BindToObject("Adaxes://rootDSE")
$searcher.SearchFilter = $filter
$searcher.SearchScope = "ADS_SCOPE_SUBTREE"
$searcher.PageSize = 500
$searcher.ReferralChasing = "ADS_CHASE_REFERRALS_NEVER"
$searcher.SetPropertiesToLoad($properties)
$searcher.VirtualRoot = $True
try
{
$searchResultIterator = $searcher.ExecuteSearch()
$searchResults = $searchResultIterator.FetchAll()
return ,$searchResults
}
finally
{
# Release resources
if ($searchResultIterator){ $searchResultIterator.Dispose() }
}
}
# Search users
$searchResults = SearchObjects "(sAMAccountType=805306368)" @("memberOf", "cn", "employeeID")
# Build report
$records = New-Object "System.Text.StringBuilder"
foreach ($searchResult in $searchResults)
{
# Check user groups
$values = $searchResult.Properties["memberOf"].Values
if ($values.Count -gt 2)
{
continue
}
# Add user to report
[void]$records.Append("<tr>")
[void]$records.Append("<td>")
[void]$records.Append($searchResult.Properties["cn"].Value)
[void]$records.Append("</td>")
[void]$records.Append("<td>")
[void]$records.Append($searchResult.Properties["employeeID"].Value)
[void]$records.Append("</td>")
[void]$records.Append("</tr>")
}
# Build html
$html = New-Object "System.Text.StringBuilder"
[void]$html.Append($reportHeader)
if ($records.Length -eq 0)
{
[void]$html.Append("<b>Users not found</b>")
}
else
{
[void]$html.Append("<table border=""1"">")
[void]$html.Append("<tr><th>Full Name</th><th>Employee ID</th></tr>")
[void]$html.Append($records.ToString())
[void]$html.Append("</table>")
}
[void]$html.Append($reportFooter)
# Send mail
$Context.SendMail($to, $subject, $NULL, $html.ToString())