0 votes

Hi All,

I am currently using the 30 day free trial of Adaxes and seeing if we can use it to achieve our method of user provisioning.

I am looking into server-side scripting and i wonder if anyone can help me.

I want to achieve the following: -

  1. New user created
  2. Powershell script runs after creation

I want the powershell to achieve the following: -

  1. Pull the newly created users employeeID
  2. Pass that employeeID value to a powershell variable
  3. Use that variable value within an SQL query

Can this be achieved?

Any help is much appreciated, Thanks

by (40 points)

1 Answer

0 votes
by (294k points)

Hello Lewis,

Yes, it is possible. You can use the below code in your script to obtain the employeeID property value. It will be saved to the $employeeID variable. The script should be executed in a business rule triggering After creating a user.

try
{
    $employeeID = $Context.TargetObject.Get("employeeID")
}
catch
{
    $employeeID = $NULL
}
0

Hi,

Thanks for your input.

I have put together a PowerShell script which uses the code you have suggested (see below)

Import-Module Adaxes
Import-Module ActiveDirectory
$databaseHost = ""
$databaseName = ""

$databaseUsername = ""
$databasePassword = ""

employeeNumber = $Context.TargetObject.Get("EmployeeID")

When running the script from a created business rule, i get the following error:-

'employeeID' found in expression: $employeeID is not defined

This suggests that the $context.targetObject.get code isn't working, as the variable is empty.

Please advise

0

Hello Lewis,

The code works perfectly fine. How exactly did you execute the script? Was it in Windows PowerShell? Please, describe the workflow you configured in all the possible details with screenshots. If you cannot post screenshots here, please, send them to us at support@adaxes.com.

0

Hi,

I have created a new Business Rule to run a powershell script after successful user creation (see below) BusinessRule.png

This Busniess Rule has the script within it that i wish to run (see below) ScriptInAdaxes.png

On creating the user (which appears in AD) i get the following error (see below) Error.png

Any help is much appreciated. Thanks

0

Hello Lewis,

The error is not related to the code we provided. As you can see from the error, it is about the query you make. Most probably, the variable is not passed properly. Unfortunately, we cannot be more specific as it is almost impossible to see the script in your screenshot.

0

Hello,

Just to let you know that i have now got it working. I had forgotten to change a variable name that passes the employeeID as part of the SQL query.

Thanks for all your help in this matter. Lewis

Related questions

0 votes
1 answer

We have a 3rd party vendor that we are able to add users based on AD security groups. What I need to do is set a parameter for the number of available licenses and whenever ... the group is 495 I would like an email to trigger telling me to add more licenses.

asked Oct 12, 2022 by A_Pastor (70 points)
0 votes
1 answer

Occationally Service Desk staff need to clear a DNS record when a desktop has been reimaged but is keeping the same name as loses the ability to manage its original DNS ... running in ADAXES. Can I just install the applet on the ADAXES server using powershell?

asked Jan 17, 2023 by stevehalvorson (110 points)
0 votes
1 answer

Hi, I am working on making a custom Approval Request notification E-mail, and I'd like to include the Approve and Deny buttons, but I haven't found a way to get ... awaiting-their-approval-s212.htm Do you have any suggestions on how to best generate the URLs?

asked Oct 29 by Martin (150 points)
0 votes
1 answer

I would like to change department without a script just yet if possible on multiple accounts. If I cant do this then I will entertain custom script Thanks :)

asked Nov 23, 2021 by will17 (350 points)
0 votes
1 answer

Using the powershell module, I know how to create a scheduled task, and also how to bind to a scheduled task that is already known. I also have used code to try creating ... same time as another. These are all one-time tasks and will be removed once executed.

asked Jan 19 by aweight (60 points)
3,588 questions
3,277 answers
8,303 comments
548,079 users