Deleting Managed users via CLI

新規投稿

コメント

6件のコメント

  • mwiller

     You're correct — you need the IDs of the users you want to delete.  One way to find those IDs with the CLI is to use the `box users search` command; the filter term argument matches against both the user name and email.

    0
    コメントアクション パーマリンク
  • hunnj

    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.

    0
    コメントアクション パーマリンク
  • mwiller

     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.

    0
    コメントアクション パーマリンク
  • mboggs

     

     

    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? 

    0
    コメントアクション パーマリンク
  • dandennhardt

     

     

    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

    0
    コメントアクション パーマリンク
  • mboggs

    Thank you, that was very helpful. 

    0
    コメントアクション パーマリンク

サインインしてコメントを残してください。