Deleting Managed users via CLI
I'm attempting to delete around 650 Managed users via the CLI
I have the list of users in a CSV File and running this command "box users delete --bulk-file-path /Users/macuser/Downloads/filename.csv"
And I get an error of
Error deleting user Walter White.
The API returned an error [NotFound | unique id here ] not_found - Not Found
I opened a case with BOX but was told I need to use the ID and not email in my CSV but there's not a way to export a list of just the users I want to delete
Any suggestions? surely i'm not the only admin that has faced this
-
Is there a way to get the "box users search" to return just the ID? I have not seen how to do this. It would be very handy if you could use the --id-only option similar to some of the other commands to grab it so you could chain it into the next command. For example I would like to create an External folder for users and assign them as co-owner, however I need to look up the ID first. Now we do this manually and take a dump to csv using "box users list -m -s --file-format CSV". I then have to parse through the CSV to grab the ID for the user. Ideally I would like to create a job which takes the users email from an input file so we could batch these, since the email is already fed over through the request form.
-
There is not currently a way to get just a user ID as output from `box users search`, but one possibility is to use `box users search --json` and pipe it to something like jq to find what you're looking for in the JSON output. I was able to do the following to get the ID of a single user:
box users search CoAdmin --json | jq -erM ".entries[0].id"
Using jq this way will return the raw ID of the first user returned from `box users search`, and will make the exit code of the command non-zero if no users were returned.
-
Was the "Box Users Search" command removed from Box CLI at some point? I just get "unexpected argument search" when I try it.
version: @box/cli/2.5.1 win32-x64 node-v13.13.0
Its also not listed here: https://github.com/box/boxcli/blob/master/docs/users.md
Follow up question, is there a way to do this if it has been removed?
-
I'm not sure why it isn't in the docs, but you can search for users
The syntax is just
box users:search yourSearchTerm
For example:
C:\Users\username>box users:search dan@ --fields=name,id,login ----- User 193973366 ----- Type: user ID: '193973366' Name: Box Admin Login: dan@company.com
I believe it implements the equivalent command with the --filter argument, for example
C:\Users\username>box users --filter=dan@ --fields=name,id,login ----- User 193973366 ----- Type: user ID: '193973366' Name: Box Admin Login: dan@company.com
Source for the command is available at https://github.com/box/boxcli/blob/master/src/commands/users/search.js
Please sign in to leave a comment.
Comments
6 comments