Skip to content

Commit c15a94c

Browse files
authored
Merge pull request #29476 from MicrosoftDocs/deniseb-fhl
deniseb fhl
2 parents fc03419 + dc1b244 commit c15a94c

1 file changed

Lines changed: 18 additions & 17 deletions

File tree

microsoft-365/solutions/per-group-guest-access.md

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Prevent guests from being added to a specific group"
33
ms.reviewer: rahulnayak
4-
ms.date: 12/02/2023
4+
ms.date: 09/17/2025
55
author: officedocspr5
66
ms.author: odocspr
77
manager: jtremper
@@ -39,7 +39,8 @@ You must use the `beta` version of [Microsoft Graph PowerShell](/powershell/micr
3939
- If you've already installed the `beta` version, run `Update-Module Microsoft.Graph.Beta` to ensure it's the latest version of this module.
4040

4141
> [!NOTE]
42-
> You must have global admin rights to run these commands.
42+
> You must have the Global Administrator role assigned in order to run these commands.
43+
> Microsoft recommends that you use roles with the fewest permissions. Using lower permissioned accounts helps improve security for your organization. Global Administrator is a highly privileged role that should be limited to emergency scenarios when you can't use an existing role. To learn more, see [About admin roles in the Microsoft 365 admin center](/microsoft-365/admin/add-users/about-admin-roles).
4344
4445
Run the following script, changing *\<GroupName\>* to the name of the group where you want to block guest access.
4546

@@ -51,13 +52,13 @@ $templateId = (Get-MgBetaDirectorySettingTemplate | ? {$_.displayname -eq "group
5152
$groupID = (Get-MgBetaGroup -Filter "DisplayName eq '$GroupName'").Id
5253
5354
$params = @{
54-
templateId = "$templateId"
55-
values = @(
56-
@{
57-
name = "AllowToAddGuests"
58-
value = "$false"
59-
}
60-
)
55+
templateId = "$templateId"
56+
values = @(
57+
@{
58+
name = "AllowToAddGuests"
59+
value = "$false"
60+
}
61+
)
6162
}
6263
6364
New-MgBetaGroupSetting -GroupId $groupID -BodyParameter $params
@@ -82,13 +83,13 @@ $templateId = (Get-MgBetaDirectorySettingTemplate | ? {$_.displayname -eq "group
8283
$groupID = (Get-MgBetaGroup -Filter "DisplayName eq '$GroupName'").Id
8384
8485
$params = @{
85-
templateId = "$templateId"
86-
values = @(
87-
@{
88-
name = "AllowToAddGuests"
89-
value = $true
90-
}
91-
)
86+
templateId = "$templateId"
87+
values = @(
88+
@{
89+
name = "AllowToAddGuests"
90+
value = $true
91+
}
92+
)
9293
}
9394
9495
$DirectorySettingId = (Invoke-GraphRequest -Uri https://graph.microsoft.com/beta/Groups/$groupId/settings -Method GET).value.id
@@ -118,7 +119,7 @@ By default, guests aren't visible in the Exchange Global Address List. Use the s
118119
Update-MgBetaUser -UserId cfcbd1a0-ed18-4210-9b9d-cf0ba93cf6b2 -ShowInAddressList -GivenName 'Megan' -Surname 'Bowen' -DisplayName 'Megan Bowen' -mobilePhone '555-555-5555'
119120
```
120121

121-
## Related topics
122+
## Related articles
122123

123124
[Collaboration governance planning recommendations](collaboration-governance-overview.md#collaboration-governance-planning-recommendations)
124125

0 commit comments

Comments
 (0)