0 votes

As we use the dateformat dd.mm.yyyy I set it as required in this format in the regesp.

Is it possible to convert the CustomAttributeText5 from "dd.mm.yyyy" in "yyyy-MM-dd" as we would need it in the email as yyyy-mm-dd format?

Or is it required to set the Regexp as desired for adm-CustomAttributeText5?

I have already tried to add this line:

$entryDate = [datetime]::ParseExact($entryDatePropertyName, "dd.MM.yyyy", $null).ToString("yyyy-MM-dd")

by (380 points)

1 Answer

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

Hello Fabian,

Of course, it is recommended to make sure that dates are directly entered in the required format to avoid any further parsing. However, the line you provided works just fine as per our check. What makes you think it does not? What exactly do you pass to $entryDatePropertyName?

0

My code:

`$entryDatePropertyName = "adm-CustomAttributeText5" # TODO: modify me

# Convert date from "dd.mm.yyyy" to "yyyy-MM-dd"

$entryDate = [datetime]::ParseExact($entryDatePropertyName, "dd.MM.yyyy", $null).ToString("yyyy-MM-dd")

# Get member property value

$member = $Context.BindToObjectByDN("%member%")

try { $memberPropertyValue = $member.Get($entryDatePropertyName) } catch { $memberPropertyValue = "already existing user" }

# Send mail

$emailBody = [System.String]::Format($emailBodyTemplate, @($memberPropertyValue)) $Context.SendMail($to, $subject, $emailBody, $NULL)` This is the error message I get from adaxes:

image.png

+1

Hello Fabian,

The behavior is expected as you are passing the property name to the parser instead of a date. Below is the updated full script.

$to = "recipient@company.com, recipient2@company.com" # TODO: modify me
$subject = "My Subject" # TODO: modify me
$emailBodyTemplate = @"
Hello,

The user %adm-MemberFullName% has been added to the %name% group.

Entry date: {0}
"@ # TODO: modify me

$entryDatePropertyName = "adm-CustomAttributeText5" # TODO: modify me

# Get member property value
$member = $Context.BindToObjectByDN("%member%")

try
{
    $memberPropertyValue = $member.Get($entryDatePropertyName)
}
catch
{
    $memberPropertyValue = "already existing user"
}

if ($memberPropertyValue -eq "already existing user")
{
    $emailBody = [System.String]::Format($emailBodyTemplate, @($memberPropertyValue))
}
else
{
    $memberDate = [DateTime]::ParseExact($memberPropertyValue, "dd.MM.yyyy", $null).ToString("yyyy-MM-dd")
    $emailBody = [System.String]::Format($emailBodyTemplate, @($memberDate))
}

# Send mail
$Context.SendMail($to, $subject, $emailBody, $NULL)
0

thank you!

Related questions

0 votes
1 answer

Just wanted to know if we could: Change the name of "Rename" Hide it altogether from the user page We've created a custom rename comand would prefer to simplify the user interface.

asked 1 day ago by msheppard (470 points)
0 votes
1 answer

It is possible to make the Self Password reset Enrollment page only available from the internal network and block it from the internet ?

asked Jan 18, 2021 by wadiheid (20 points)
0 votes
1 answer

We are testing Windows Autopilot and would still like to use the adaxes client to allow for SSPR. Is it possible to configure the Windows Integration settings on a machine that is not domain joined but is joined through Azure AD?

asked Sep 3, 2020 by scoutcor (120 points)
0 votes
1 answer

Is it possible to only allow a user to unlock their account from the web interface? We have a group of Mac users who we'd like to be able to unlock their accounts through the web but use a different service for changing their passwords.

asked Jun 30, 2020 by scoutcor (120 points)
0 votes
1 answer

For creating a computer object, we want to check if the entered CN is already used in our AD. And for that we want to use a powershell script. An other dot ... powershell script should be start before creating the computer object, right? Thanks for your help.

asked Jun 4 by KEME (80 points)
3,548 questions
3,239 answers
8,232 comments
547,814 users