Hello,
Here' s a script that you can use to generate the report you need:
Import-Module Adaxes
$email = "%adm-InitiatorEmail%"
if ($email -eq "")
{
$Context.LogMessage("No e-mail addresses specified for your account.", "Information")
return
}
$baseContainerDN = "%distinguishedName%"
$domainName = $Context.GetObjectDomain($baseContainerDN)
$bodyBuilder = New-Object "System.Text.StringBuilder"
$bodyBuilder.append("<html><head>") | Out-Null
$bodyBuilder.append("<meta http-equiv=""Content-Type"" content=""text/html charset=UTF-8""></head>") | Out-Null
$bodyBuilder.append("<body>") | Out-Null
$bodyBuilder.append("<table width=""100%%"" border=""1"">") | Out-Null
$bodyBuilder.append("<tr>") | Out-Null
$bodyBuilder.append("<th>DN</th><th>CN</th><th>Display Name</th><th>adm-PasswordExpires</th>") | Out-Null
$bodyBuilder.append("</tr>") | Out-Null
# Find all users
$users = Get-AdmUser -Filter "*" -SearchBase $baseContainerDN -Properties "DisplayName" -Server $domainName -AdaxesService "localhost"
$passwordExpiresConverter = [Softerra.Adaxes.Utils.PropertyValueConverter]::GetConverter("adm-PasswordExpires", "LargeInteger")
foreach ($user in $users)
{
$admUser = $Context.BindToObjectByDN($user.DistinguishedName)
$passwordExpires = $passwordExpiresConverter.ConvertToString($admUser.Get("adm-PasswordExpires"))
$bodyBuilder.append("<tr>") | Out-Null
$bodyBuilder.appendFormat("<td>{0}</td>", $user.DistinguishedName) | Out-Null
$bodyBuilder.appendFormat("<td>{0}</td>", $user.Name) | Out-Null
$bodyBuilder.appendFormat("<td>{0}</td>", $user.DisplayName) | Out-Null
$bodyBuilder.appendFormat("<td>{0}</td>", $passwordExpires) | Out-Null
$bodyBuilder.append("</tr>") | Out-Null
}
$bodyBuilder.append("</table>") | Out-Null
$bodyBuilder.append("</body></html>") | Out-Null
$Context.SendMail($email, "[AD Report] Inactive Computers", $null, $bodyBuilder.ToString())
This script can be used in a Custom Command or a Scheduled Task. To create a Custom Command that launches this script:
- Launch the Custom Command creation wizard.
- On the 2nd step of the wizard, enable the Show all properties checkbox, and select the Domain-DNS object type.
- On the 3rd step, click the Add Action link and choose the Run a program or a PowerShell script action.
- Paste the script above in the Script field.
- Follow the instructions of the wizard and finalize creation of the Custom Command.
When executed on a domain, the Custom Command will compose a report for all the users within this domain and send the report to the initiator.