We have been checking to see who users were most recently disabled so we can manually check a few things. Here is the code I used to get that information using the Scheduled Tasks.
I realize that the web interface offers this same functionality, which is actually much easier. But this worked well for us.
Note, this is modified from a template I received from a previous post (Email when there is a problem). The instructions for creating the script can be followed in that post.
import-module Adaxes
$numDays = -10
$to = "itnotify@domain.com" ## TODO: Change this
$subject = "Adaxes users disabled within the last $numDays days"
$htmlReportHeader = @"
<b>Adaxes users disabled in the last $numDays days</b><br/><br/>
<table border="1">
<tr>
<th>User</th>
<th>Modified date</th>
</tr>
"@
$Report_body = Get-AdmUser -LDAPFilter {(useraccountcontrol:1.2.840.113556.1.4.803:=2)} -Properties whenChanged | Where-Object {$_.whenChanged -gt (Get-Date).AddDays($numDays)} | Select-Object Name, whenChanged
$htmlReportFooter = "<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
$count=0
foreach ($record in $Report_body)
{
$recordName = $record.Name
$recordModified = $record.whenchanged
$htmlReportHeader += "<tr valign='top'><td>$recordName</td><td>$recordModified</td></tr>"
$count++
}
$htmlBody = $htmlReportHeader + "</table><p>Total Users: $count </p>" + $htmlReportFooter
# Bind to the Service Log
$path = $Context.GetWellKnownContainerPath("ServiceLog")
$serviceLog = $Context.BindToObject($path)
#Write-Output $htmlBody
if ($Report_body)
{
# Send report
$Context.SendMail($to, $subject, $NULL, $htmlBody)
}
I hope someone finds it useful!