# Wie man ein Skript zum "Massentrennen" aus einer Gruppe erstellt?

**URL:** https://meta.discourse.org/t/how-to-create-a-script-to-bulk-remove-from-a-group/56614
**Category:** Support
**Created:** [30. Januar 2017 um 20:45 UTC](https://meta.discourse.org/t/how-to-create-a-script-to-bulk-remove-from-a-group/56614 "2017-01-30T20:45:36Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Selk68](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/selk68/32/67080_2.png) [@Selk68](https://meta.discourse.org/u/Selk68)
#### Post date: [30. Januar 2017 um 20:45 UTC](https://meta.discourse.org/t/how-to-create-a-script-to-bulk-remove-from-a-group/56614/1 "2017-01-30T20:45:36Z")

</div>

Continuing the discussion from [Bulk add to Group](https://meta.discourse.org/t/bulk-add-to-group/34979/15):

> [@Falco](#):
>
> I took a step back and rewrote everything in a nice script that reads from a database using sequel and writes to Discourse with the api, adding and removing users everyday at midnight. Put it on Jenkins and never looked back.

@Falco and all, this is something that I would like to be able to do on the forum that I help run.

We have one category for “Members Only” - that is restricted to only our paid/active members - that I am able to import a list of users who currently have active accounts in our Active Directory through the Web Interface; however, there is no easy way to do a bulk remove of members who are no longer active from the group using the Web Interface.

I do have access to the server side and one of our admins already has a script to export the active accounts to a CSV file that includes the e-mail addresses of all currently active members; however, I do not know how to create a script that would remove all members from the restricted group on our forum, then add only the currently active members back to it (_which sounds like basically what you are doing…_). This is something that I would like to have done daily, as mentioned in the post quoted above.

Can you give me any pointers, please?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [30. Januar 2017 um 23:24 UTC](https://meta.discourse.org/t/how-to-create-a-script-to-bulk-remove-from-a-group/56614/2 "2017-01-30T23:24:20Z")

</div>

I think that what you want to do is have your developer use API calls to update Discourse when changes are made to the accounts rather than export a CSV daily. I’ve written one for the Wordpress MemberMouse plugin (I think that’s what it was).

Failing that, you might want a list of users to delete and a list of those to add, and then do something to check that both lists are actually in sync.

> [@Discourse REST API Documentation](https://meta.discourse.org/t/discourse-api-documentation/22706):
>
> Discourse API Please view the Discourse API Documentation site for detailed info: [https://docs.discourse.org](https://docs.discourse.org)information_source Authentication API requests must use HTTP header based authentication. Pass your Api-Key and Api-Username as HTTP headers. Authentication via query parameters or request body is not supported (this was removed in April 2020). Please see the example cURL request below. The only API endpoints that continue to support credentials in query parameters are requests to…

---

<div class="post-metadata">

### Author: ![Selk68](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/selk68/32/67080_2.png) [@Selk68](https://meta.discourse.org/u/Selk68)
#### Post date: [31. Januar 2017 um 00:02 UTC](https://meta.discourse.org/t/how-to-create-a-script-to-bulk-remove-from-a-group/56614/3 "2017-01-31T00:02:55Z")

</div>

Thanks for taking the time to help, @pfaffman!

The reason we export the CVS daily is because we do not have our forum tied directly into our AD accounts. It was setup like that to allow anyone to register for an account on our forum. Even though we do not have our discourse instance tied into Active Directory authentication, will the API be able to pull the information from AD? (_I was previously advised by some who do most of the developing for our forum that it would be best to have the active accounts exported from AD, then imported into the custom group… I am open to other options though._).

Thanks again!  
😃

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [31. Januar 2017 um 00:52 UTC](https://meta.discourse.org/t/how-to-create-a-script-to-bulk-remove-from-a-group/56614/4 "2017-01-31T00:52:49Z")

</div>

> [@Selk68](#):
>
> The reason we export the CVS daily is because we do not have our forum tied directly into our AD accounts.

Unless the computer managing the AD accounts is not connected to the internet, then it could update Discourse when changes are made to those accounts.

> [@Selk68](#):
>
> will the API be able to pull the information from AD

No. The AD server will be generating the API calls.

I think my point is that whatever code is generating the CSV file could just as easily generate the API calls necessary to do the updates.

---

<div class="post-metadata">

### Author: ![Selk68](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/selk68/32/67080_2.png) [@Selk68](https://meta.discourse.org/u/Selk68)
#### Post date: [31. Januar 2017 um 21:07 UTC](https://meta.discourse.org/t/how-to-create-a-script-to-bulk-remove-from-a-group/56614/5 "2017-01-31T21:07:54Z")

</div>

Awesome! That’s great to know!!

I’ll ask around the 'Space (_our makerspace, that is…_) to see if someone can help me learn how to configure it!

Thanks again, I _ **really** _ appreciate it!! 😃

---

<div class="post-metadata">

### Author: ![Vishal.Kshirsagar](https://avatars.discourse-cdn.com/v4/letter/v/2bfe46/32.png) [@Vishal.Kshirsagar](https://meta.discourse.org/u/Vishal.Kshirsagar)
#### Post date: [14. November 2021 um 07:20 UTC](https://meta.discourse.org/t/how-to-create-a-script-to-bulk-remove-from-a-group/56614/6 "2021-11-14T07:20:14Z")

</div>

Hallo @Selk68 @pfaffman Hallo, ich suche nach einer Lösung, um Benutzer in großen Mengen zu entfernen. Ich verstehe, dass dies durch Skripting erfolgen kann. Können Sie bitte weitere Details dazu mitteilen, wie das Skript auf der Plattform ausgeführt wird? Oder ist dies etwas, das nur ein Entwickler tun kann?

Außerdem habe ich von AD gelesen. Können Sie bitte erklären, wie es funktioniert und wie wir AD mit Discourse synchronisieren können?  
Vielen Dank.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [14. November 2021 um 09:53 UTC](https://meta.discourse.org/t/how-to-create-a-script-to-bulk-remove-from-a-group/56614/7 "2021-11-14T09:53:12Z")

</div>

Sie können sich die [Administrative Bulk Operations](https://meta.discourse.org/t/administrative-bulk-operations/118349) ansehen. Dort sollten einige Hinweise zu finden sein.

Wenn mit AD das Windows Active Directory gemeint ist, würde ich davon abraten, es sei denn, Sie sind bereits fest darin eingebunden. Ich glaube, es gibt möglicherweise etwas, das es Ihnen erlaubt, es als SSO zu verwenden, aber Sie müssten mir viel Geld zahlen, um das herauszufinden.

---

<div class="post-metadata">

### Author: ![Vishal.Kshirsagar](https://avatars.discourse-cdn.com/v4/letter/v/2bfe46/32.png) [@Vishal.Kshirsagar](https://meta.discourse.org/u/Vishal.Kshirsagar)
#### Post date: [14. November 2021 um 11:30 UTC](https://meta.discourse.org/t/how-to-create-a-script-to-bulk-remove-from-a-group/56614/8 "2021-11-14T11:30:59Z")

</div>

Hallo @pfaffman Vielen Dank für Ihre Zeit und Ihre Antwort. Ich werde die administrative Massenoperation mit der Kommandozeile untersuchen.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [8. Juni 2024 um 12:36 UTC](https://meta.discourse.org/t/how-to-create-a-script-to-bulk-remove-from-a-group/56614/9 "2024-06-08T12:36:49Z")

</div>

Dieses Thema wurde nach 2685 Tagen automatisch geschlossen. Neue Antworten sind nicht mehr möglich.
