ADDUSERS - CMD
Overview
ADDUSERS is a command-line utility in Windows that enables the batch creation, modification, or deletion of user accounts. It can also export existing account profiles. This command is particularly useful in large organizations or network environments where managing multiple user accounts efficiently is required.
Syntax
The ADDUSERS command has different syntax depending on its intended function, whether adding, deleting, or exporting users:
ADDUSERS [/s:x /d{:u | :c} [{/f:filename | /p:{l | c | e | d}}]] [/c:filename]
- /s:x – Specifies the character used as a delimiter in the CSV file (default is ,).
- /d – Directive to add users. The option can be
:uto create users,:cto create users and add them to groups. - /f:filename – Specifies the CSV file used for user account operations.
- /p:x – Sets the password requirements where
lis for blank passwords,cfor user must change password,efor password never expires, anddfor disabled account. - /c:filename – Used for exporting users; specifies the CSV file to which user profiles should be exported.
Options/Flags
- /s:x – Changes the default delimiter in CSV files, allowing flexibility with file formats.
- /d – Determines the mode of operation for adding users with variations for user creation and group additions.
- /f:filename – Indicates the file from which to read or write user data. Essential for batch operations.
- /p:x – Configures password properties, critical for security and compliance with organizational policies.
- /c:filename – Specifies the output file when exporting user data, useful for backups or migrations.
Examples
1. Adding Users:
To add users from a CSV file named users.csv where the user must change the password at the next logon:
ADDUSERS /d /f:users.csv /p:c
2. Exporting User Accounts:
Export current user accounts into a file named export.csv:
ADDUSERS /c:export.csv
Common Issues
- File Format Errors: If the CSV file is not correctly formatted,
ADDUSERSmight fail to parse it. Ensure the CSV adheres to the expected structure with appropriate headings and delimiters. - Permission Issues: Running
ADDUSERSwithout sufficient permissions can lead to failures. Ensure it’s run with administrative privileges.
Integration
Integrate ADDUSERS with other commands for powerful scripting. Example with FOR loop to process multiple files:
FOR %f IN (users1.csv, users2.csv) DO ADDUSERS /d /f:%f /p:e
This script processes multiple CSV files, adding users with passwords set to never expire.
Related Commands
- NET USER: Allows detailed management of user accounts directly.
- WMIC: Interface for system management including user accounts.
For further reading and more detailed information, refer to the official Microsoft documentation or resources like TechNet. These can provide deeper insights into advanced usage scenarios and additional flags.