# Powershell script to replace usergroup in SPO

**URL:** <https://forums.powershell.org/t/powershell-script-to-replace-usergroup-in-spo/15309>\
**Category:** PowerShell Help\
**Created:** [November 29, 2020, 9:52pm UTC](https://forums.powershell.org/t/powershell-script-to-replace-usergroup-in-spo/15309 "2020-11-29T21:52:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulus](https://avatars.discourse-cdn.com/v4/letter/p/e19b73/32.png) [@paulus](https://forums.powershell.org/u/paulus)\
**Post date:** [November 29, 2020, 9:52pm UTC](https://forums.powershell.org/t/powershell-script-to-replace-usergroup-in-spo/15309/1 "2020-11-29T21:52:24Z")

</div>

Hi,

I’m new here so sorry if I posted this wrong or maybe for the 100th time.

The usergroup “Visitors” in SPO contain a modified AAD group named “AllusersexceptABmembers”, is there a way to use a script or command within PowerShell to replace this group with the group “AllenabledAzureUsers”. If not I have to manually replace this within around 700 SPO sites.

Thnx.

---

<div class="post-metadata">

**Author:** ![rob-simmers](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/rob-simmers/32/1010_2.png) [@rob-simmers](https://forums.powershell.org/u/rob-simmers)\
**Post date:** [November 30, 2020, 6:39am UTC](https://forums.powershell.org/t/powershell-script-to-replace-usergroup-in-spo/15309/2 "2020-11-30T06:39:57Z")

</div>

Have you done any research? There are many factors such as SharePoint versions. A quick search ‘powershell sharepoint group members update’ you can get plenty of links to review such as:

> **[Manage SharePoint Online users and groups with PowerShell - Microsoft 365...](https://docs.microsoft.com/en-us/microsoft-365/enterprise/manage-sharepoint-users-and-groups-with-powershell?view=o365-worldwide)**
>
> In this article, learn how to use PowerShell for Microsoft 365 to manage SharePoint Online users, groups, and sites.

Replace would basically be a Remove of the old group and Add of the new group.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:28pm UTC](https://forums.powershell.org/t/powershell-script-to-replace-usergroup-in-spo/15309/3 "2024-05-16T20:28:15Z")

</div>

Closed on May 16, 2024, 8:28pm UTC


