ArcGIS Portal Housekeeping using ArcPy

02-27-2020 07:52 PM
New Contributor II

Hi All,

I created a code to remove inactive users from Portal after 90 days of inactivity.
The code runs through the list of users and removes users who have not logged in since 90 days and reassigns their content to Portal administrator.

Is there a way I can delete users who do not have any content on Portal?
I can loop in throgh the list of users but to check wherther they have content or not seems like a challange.
Any suggestions?

If required I can provide code snippets.


0 Kudos
2 Replies
MVP Regular Contributor

When looping through the users, just do a content search for all items owned by a particular user and then check the length of the list.  If the length is 0, then you can delete the user.  

search_result ="owner:" + userName, item_type="", max_items = 99999, outside_org=False)
New Contributor II

Thank you for your response William . I will give it a try .
By right, this seems to be the only and correct method of checking content.

0 Kudos