script to add bulk of users to UserMan

hi there ,
i’m looking for script to add bulk of users to UserManager , i know how to add single user and assign profile to it .
any suggestions

Have you consider using the api ?

With curl (Linux/Windows) for example, or with powershell with cmdlet ´Invoke-WebRequest´.
In powershell you have to use curl.exe to get curl command, so you don’t get the powershell alias to cmdlet ´Invoke-WebRequest´.

Using like a csv file for example.

currently i want to use simple ssh

You’re going to have to provide more details on what you’re looking for and what your starting with…

i.e.

  • what version of RouterOS?
  • is user manager already setup and working for users, and ONLY bulk add is needed?
  • do you want user manager to generate users (i.e. /user-manager/user add-batch-users)? or… you already have some list of users (like CSV) you want to add in bulk?
  • do you want it run on RouterOS, or use ssh from another PC?
  • etc…

Good evening, I’m currently looking to use the “add-batch-user” function in mikrotik Ros v7.18 (CHR) user-man to generate users? with curl, windows powershell, or using Postman. Can you show me an example? The PUT method only works on http://ip-router/rest/user-manager/user not on http://ip-router/rest/user-manager/user/add-batch-user and POST of http://ip-router/rest/user-manager/user/ result an error of bad command. Thank you

There is no batch-add-user AFAIK in V6 — but I’m not the expert on UM under V6.

You should be able to use a for loop to add users. You’d have to adapt to your needs, but essentially something like:

:for n from=1 to=100 do={
/user-manager/user add name=“user$n” …
}

(where the $n is a number from 1 to 100 — the the to= to use less users, or from from= if you want to add more users after the first round)

You need to use POST with http://ip-router/rest/user-manager/user/add-batch-user. It will NOT work with a PUT or GET, since it’s an operation. That means you need to have JSON in body with attributes for the add-batch-user.

[/quote]
You need to use POST with http://ip-router/rest/user-manager/user/add-batch-user. It will NOT work with a PUT or GET, since it’s an operation. That means you need to have JSON in body with attributes for the add-batch-user.
[/quote]

Thank you for your answer, but I always get the error “detail”: “no such command”, (in the screenshot)
NB: “username-length”: 6,
Capture d'écran 2025-04-20 204042.png

The JSON in photo is wrong "username-length" & the URL is …/add-batch-users — likely BOTH are your issue.

Using CURL with 7.19beta, the following worked (*changed password/ip):

curl -k 'https://192.168.88.1/rest/user-manager/user/add-batch-users' --json `jo number-of-users=1 username-length=8` --user adminusernmame:somepassword

Again, the add-batch-user**s** command — AFAIK — new in V7 user-manager. I do not believe it’s in V6 (although don’t have any V6 UM installs to check)

( On v6 web interface exist “add batch” and you can download the list of generated users. )