0 votes

Hello,

I was wondering, is it possible to update existing user accounts in AD by CSV import?

More specifically, updating user account passwords by CSV file?

Regards,

Jay

by (90 points)

1 Answer

0 votes
by (216k points)

Hello Jay,

For this purpose, you can use PowerShell scripts. You can create PowerShell scripts that import the properties you need and update user accounts. You can combine your scripts with Adaxes Business Rules, Custom Commands and Scheduled Tasks to perform import when a certain operation is performed, on request or on schedule.

For example, the following script imports new passwords for users from a CSV file:

Import-Module Adaxes

$file = "\\SERVER\Share\import.csv"
$usersToModify = Import-CSV $file
if ($usersToModify -eq $NULL)
{
    $Context.LogMessage("Failed to read data from '$file'.", "Error")
    return
}

$domain = $Context.GetObjectDomain("%distinguishedName%")
foreach ($item in $usersToModify)
{
    try
    {
        $newPassword = ConvertTo-SecureString -AsPlainText $item.AccountPassword -Force
        Set-AdmAccountPassword $item.SamAccountName -Reset -NewPassword $newPassword -AdaxesService localhost -Server $domain -ErrorAction Stop
    }
    catch [System.Exception]
    {
        $Context.LogMessage($_.Exception.Message, "Error")
    }
}

In the script, $file specifies the path to the CSV file with user passwords. Modify the script to your requirements.

The CSV file should contain two columns. One of the columns should have the SamAccountName header. It will specify the User Logon Name (pre-Windows 2000) of the users, whose passwords need to be reset. The other column with header AccountPassword will contain the new passwords. Example of such a CSV file:

SamAccountName,AccountPassword
user1,p@$$w0rd1
user2,p@$$w0rd2
user3,p@$$w0rd3

To execute the script with the help of a Business Rule, Custom Command or Scheduled Task, you can use the Run a program or PowerShell script action. For example, to create a Scheduled Task that runs the script on a schedule:

  1. Create a new Scheduled Task.
  2. On the 3rd step of the Create Scheduled Task wizard, select Show all object types and select the Domain-DNS object type.
  3. On the 4th step, add the Run a program or PowerShell script action and paste the above script in the Script field.
  4. On the 5th step, include the domain, where you want to change passwords for users, in the Activity Scope of the Task.

Related questions

0 votes
1 answer

We are running a daily or weekly job that is updating certain attributes in AD for 9000k users. It appears to not be cycling through after the 10 minute stop. We need ... users are completed in the 10 minutes but it doesn't start again automatically with 701.

asked May 30, 2017 by willy-wally (3.2k points)
0 votes
1 answer

hello i'm new with Adaxes i'm try to creat schuadle task to import a spefice user list by thier username id after that just update City for them by bulk updating . kinly advise

asked Aug 29, 2023 by sudox (20 points)
0 votes
1 answer

Hello, How it works if I have multiple accounts in one domain, and other accounts in others domains managed by Adaxes ? Thank you. Regards. Pierre

asked Jun 9, 2021 by pierre.saucourt (40 points)
0 votes
1 answer

Would "updating a user" also be triggered when "creating a user"? So for example, if I set a Business Rule trigger to modify a user when their user account is changed, would ... and I could not find one. If there is a document that covers this let me know.

asked Jan 17, 2023 by mobosys (290 points)
0 votes
1 answer

This script description says it can find the manager via FullName Distinguished name or Display name. Wondering if we can change it to use employeeID or SamAccountName.

asked Oct 24, 2022 by mightycabal (1.0k points)
3,549 questions
3,240 answers
8,232 comments
547,814 users