VMware Workspace ONE Community
MikaelMalmstrm
Contributor
Contributor

Automate or script delete of inactive users

Hi

I tries to find a automated way to delete inactive users. I cannot find any way to do this but maybe I have missed it. If that's not possible is it possible with a script running to API to do the same? I also tries to find a way to delete all users that has not any enrolled device and not member of any user group. Is that possible.
We are on a shared SaaS environment so we do not have access to the database and manually is not possible as we talking of delete around 20000 users in three different environments.

Best Regards
Micke
Labels (1)
0 Kudos
7 Replies
MikaelMalmstrm
Contributor
Contributor

Hi

No one have a clue?

BR Micke
0 Kudos
freesixfreesix
Contributor
Contributor

Hi, I can help you to achieve this... but at a cost.


Feel free to contact me if you still need.

0 Kudos
AlexanderVerbit
Contributor
Contributor

Hello, you can make it with three steps:
first: /api/system/search?pagesize=5000
It will get to you json with users,  after that make cicle, which get all users with ['Users']['Status'] = False
(it's your inactive users), you get ID of those users  after that yo can call api
/api/system/users/{id}/delete for that inactive users
i try it on 150 000 users, i't not fast, but work, 20 000 i think it's about 2-3 hours of work script
0 Kudos
BhargavaPonnuru
Contributor
Contributor

Hi Alexander,

Thank you for the info. We must have API integration in place in order to make API calls to delete in-active users. Isn't it, correct me if I am wrong

0 Kudos
AlexanderVerbit
Contributor
Contributor

hello Bhargava ,

yes, i think you need API integrate, but as i know, by default it set up in AirWatch.

0 Kudos
BhargavaPonnuru
Contributor
Contributor

Thank you Alexander for the info.

I managed to enable REST API in my test lab using basic authentication and have REST API URL under site URLs too.  I've configured server throttling and daily quota limits per minute and per day under advanced tab. Now, need a bit of help in fetching in-active user extract using API and how to delete them using API?

Appreciate your help here.
0 Kudos
AlexanderVerbit
Contributor
Contributor

Hello,

/api/system/users/search

this commang give to you users,

    {
      ' UserName' : ' User Name' ,
      ' FirstName' : ' xxxxx' ,
      ' LastName' : ' yyyyy' ,
      ' Status' : true,
      ' Email' : ' y@y.com' ,
      ' SecurityType' : 1,
      ' ContactNumber' : ' 2-123-123123' ,
      ' MobileNumber' : ' ' ,
      ' MessageType' : -1,
      ' EmailUserName' : ' blabla' ,
      ' Group' : ' xxxx' ,
      ' LocationGroupId' : ' 571' ,
      ' OrganizationGroupUuid' : ' a432r4werfwsr23r543423re' ,
      ' Role' : ' External Access' ,
      ' EnrolledDevicesCount' : ' 3' ,
      ' CustomAttribute1' : ' wwww' ,
      ' ExternalId' : ' 08ec1c6a-re324-4acc-bc91-3232ewewe' ,
      ' StagingMode' : 0,
      ' DeviceStagingEnabled' : false,
      ' Id' : {
        ' Value' : 123
      },
      ' Uuid' : ' rere434-f69d-4f11-3234-erer34'
    }

after that you can filter users  by ' Status'   field.   inactive users will have status  ' false'

also you can use field ' EnrolledDevicesCount'  to ensure to not delete users with devices,  users withoud enrolled devices will have there empty string ' '


delete user you can with command

/api/system/users/{id}/delete

id you also can get from first API response


p.s. also API have command /api/system/users , which  must give users list, but i  didn't get success with this command yet, try method which i describe above
0 Kudos