Hello,
Here's a PowerShell script that generates a list of all groups whose ExtensionAttribute1 equals 001 and sends it by e-mail to a certain recipient. In the script:
- $class - specifies the group 'class'
- $to - specifies the recipient of the report
- $subject - specifies the subject of the e-mail notification with the report
- $reportHeader - specifies the report header
- $reportFooter - specifies the report footer
Modify the above as necessary.
The script:
$class = "001" # TODO: modify me
$to = "recipient@domain.com" # TODO: modify me
$subject = "Groups with class '$class'" # TODO: modify me
$reportHeader = "<h2><b>Groups with class '$class'</b></h2>" # 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
$reportHeader += "<ol>"
# 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")
}
# Find all groups with the specified class
# Set search parameters
$searcher = $Context.BindToObject("Adaxes://rootDSE")
$searcher.SearchFilter = "(&(objectCategory=group)(extensionAttribute1=$class))"
$searcher.SearchScope = "ADS_SCOPE_SUBTREE"
$searcher.ReferralChasing = "ADS_CHASE_REFERRALS_NEVER"
$searcher.PageSize = 500
$searcher.SetPropertiesToLoad(@("objectGuid"))
$searcher.VirtualRoot = $True
# Build group list
try
{
$searchResult = $searcher.ExecuteSearch()
foreach ($groupId in $searchResult.FetchAll())
{
$displayName = $Context.GetDisplayNameFromAdsPath($groupId.AdsPath)
$guid = [Guid]$groupId.Properties["objectGuid"].Value
$reportHeader += "<li><a href='$webInterfaceAddress`ViewObject.aspx?guid=$guid'>$displayName</a></li>"
}
}
finally
{
$searchResult.Dispose()
}
$reportHeader += "</ol>"
# Build the report
$report = $reportHeader + $reportFooter
# Send mail
$Context.SendMail($to, $subject, $NULL, $report)