Hi,
How to export a csv list of members in a specific group in enterprise? I am able to generate some of its data: owner, Title, Date creation, date modified... I am using Notebook in ArcGIS Pro.
thanks in advance for your help.
update: I am able to generate using this tool:
PanunTools/docs/README_CreateGroupMemberListAGOL.md at main · mpanunto/PanunTools · GitHub
But I am still very keen to know how to run in from notebook.
thank you!
I have a notebook I use to write out all the users that belong to a specific group to a CSV. Is that all you need?
@Daniel yes please. Thanks in advanced.
import os,csv,time
# group name to search for
group_name = 'GROUP NAME'
group = gis.groups.search(query=f'title:{group_name}')[0]
#get all the group members
accountList = group.get_members()
# create new csv file
csv_path = os.path.join(os.getcwd()+ "_Users_" + time.strftime("%b%d%Y_%H%M%S") + ".csv")
# open and write to csv
with open(csv_path, 'w',newline ='') as output:
dataWriter = csv.writer(output)
try:
# Write list to CSV
dataWriter.writerows(accountList['users'])
except:
print("count not write the list ")
output.close()
It's not perfect but it should work.
You will need to get a GIS object and input the group name you want to search for