0 votes

I need a report script that will email me a list of the users with these field values:
DN,cn,display name,%adm-PasswordExpires%

Thanks!

by (360 points)

1 Answer

0 votes
by (216k points)
selected by
Best answer

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:

  1. Launch the Custom Command creation wizard.
  2. On the 2nd step of the wizard, enable the Show all properties checkbox, and select the Domain-DNS object type.
  3. On the 3rd step, click the Add Action link and choose the Run a program or a PowerShell script action.
  4. Paste the script above in the Script field.
  5. 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.

0

Worked Perfect, Thank you!

Related questions

0 votes
1 answer

Hi, we are using a scheduled job in Adaxes to notify users that their password will expire in x days. Now, we as IT were approached by Marketing to set up all ... ;/div&gt; &lt;/body&gt; &lt;/html&gt; Your help would be highly appreciated kind regards Ingemar

asked Mar 2, 2015 by ijacob (960 points)
0 votes
1 answer

We have the following script we need fixed to run within Adaxes to add true/false value to a customattribute for use in building dynamic distribution lists. $users = ... } else { Set-Mailbox -Identity $user.Name -CustomAttribute8 "Individual contributor" } }

asked Jul 13, 2022 by willy-wally (3.2k points)
0 votes
1 answer

When running the script that creates a custom alphabet for the Adaxes spell out feature located here: https://www.adaxes.com/help/AlphabetForPasswordSpellOut/ I receive an error ... changed the language code to "en" and the content of the alphabet object.

asked Mar 23, 2023 by jhicks (20 points)
0 votes
0 answers

Trying to configure a custom launcher in Thycotic Secret Server that will launch Adaxes on the user's local machine with the username and password passed as parameters. Has anyone made this work?

asked May 20, 2022 by amillard (20 points)
0 votes
1 answer

We have multiple secondary domains that are being managed by Adaxes. Everything seems to be working except self service portal login. We tested with our other secondary domains and those ... other than sign failed. What else can I look at to figure this out?

asked Aug 21, 2020 by mark.it.admin (2.3k points)
3,549 questions
3,240 answers
8,232 comments
547,814 users