0 votes

Hello team,

our users are created by HR system into AD and have the start date as string in extensionAttribute2 with a prefix (like "startdate_2024-01-02").

Sometimes the user does not start and disabled account will remain in AD and I would like to find them with a report and send to HR.

I would like to create a report showing me all accounts

  • disabled
  • extensionAttribute2 is before today plus 30 days (for today: show every one with startdate before 26.04.2024)
  • description contains "Employee"

Do you have a script in place to achieve this?

Thanks in advance.

by (1.5k points)

1 Answer

0 votes
by (288k points)

Hello,

Unfortunately, we do not have the exact script. However, the below articles should be helpful. Pay attention that the script will take quite long time to generate as you will need to parse the date separately for each user and then add them to the report or not.

0

Would it be easier to extract the date and store it in a custom date field? I know I can not use them to filter directly, but maybe in script to search?

0

Hello,

Unfortunately, there is no such possibility. Adaxes custom attributes (e.g. CustomAttributeDate1) cannot be used in any search queries including those executed in scripts.

0

Ok, I need some help please

I have this code and getting results, however no entry is formatted (meaning if statement is never true)

$today = (Get-Date).AddDays(-1)
$criteria = New-AdmCriteria "user" { (accountDisabled -eq $True) -and (description -contains "DRAFTEE") }
$Context.DirectorySearcher.AddCriteria($criteria)

try {
    $searchIterator = $Context.DirectorySearcher.ExecuteSearch()
    while ($Context.MoveNext($searchIterator)) {
        $startDate = "%adm-CustomAttributeDate1%"
        if($startDate -eq $today){
            $searchResult = $searchIterator.Current
            $textColor1 = "red"
            $backgroundColor1 = $null # default
            $fontStyle1 = "ADM_LISTITEMFONTSTYLE_BOLD" # bold
            $style1 = $Context.Items.CreateItemStyle($textColor1, $backgroundColor1, $fontStyle1)
            $Context.Items.Add($searchResult, $style1)    
        } else {
            $searchResult = $searchIterator.Current
            $Context.Items.Add($searchResult)
        }
    }
} finally {
    if ($searchIterator) { 
        $searchIterator.Dispose() 
    }
}

I tried to extract and convert the date from extensionAttribute3 - but no luck

$startDateString = $searchResult.Properties["extensionAttribute3"].Value
$startDateString = $startDateString.Replace("startdate_","")
$startDate = [Datetime]::ParseExact($startDateString, 'yyyy-MM-dd', $NULL)
0

Hello,

You cannot use value references in the script as they will resolve for the user generating the report. Not separately for each use found. That is why you need to extract the custom date attribute value for each account found separately and then compare it with the current date according to your requirements.

As for the text attribute parsing part, it is not related to Adaxes in any way. This is pure PowerShell. If you prefer this approach, we recommend you to check the corresponding documentation and forum threads for solutions.

The following script from our repository will also be helpful: https://www.adaxes.com/script-repository/users-with-date-stored-in-text-attribute-older-than-selected-s642.htm.

Related questions

0 votes
1 answer

Is it possible to create a drop down that displays options based on the selection in another field? EX: I want to create a job title background that will populate options ... like the Job title drop down to display "Customer service rep, call support, etc".

asked Oct 11, 2021 by copatterson (70 points)
0 votes
1 answer

This is for license purposes and we do not want them visible in the Adaxes portal.

asked Oct 22, 2021 by jfrederickwl (20 points)
0 votes
1 answer

We would like to have a business unit that is based on an adaxes custom attribute. I don't see a way of doing this. Do you all have any ideas?

asked May 18, 2020 by mark.it.admin (2.3k points)
0 votes
1 answer

Is it possible to script having users added (or removed) from a Security Group based on another AD Attribute? I have found ways to do this in Powershell (something like): ... just utilize the PS script and just run it through Adaxes on a timed fashion? Thanks!

asked Oct 7, 2014 by PunkinDonuts (360 points)
0 votes
1 answer

Is it possible to assign a role based on an attribute variable? Basically, where we have users with secretary's I'd like to create a role that allows them to update ... trying to make it a conditional check e.g. use %assistant% as a trustee definition. Thanks

asked May 20, 2013 by firegoblin (1.6k points)
3,538 questions
3,229 answers
8,224 comments
547,752 users