You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please run Get-Module Microsoft.Graph* after cmdlet execution and paste the output below.
If a module cannot be installed or imported, please run Get-Module -ListAvailable and paste the output.
ModuleType Version Name ExportedCommands
Please run $PSVersionTable and paste the output below. If running the Docker container image, indicate the tag of the image used and the version of Docker engine.
Name Value
I can see you've been following the guide from the link you've provided. Normally cmdlets with New-Mgxxxxx are things that are creating new things (new users, new groups etc). So running that command twice would try to create two different sets of settings against the same group (which is why you're getting the error you are). So, given that you've already created the setting to set it to false, and have indicated that you're trying to toggle back, have you tried using: Update-MgBetaGroupSetting instead of New-MgBetaGroupSetting?
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.
Thanks for reporting the bug. Please ensure you've gone through the following checklist before opening an issue:
Describe the bug
** Prevent guests from being added to a specific group | Microsoft Learn
Prevent guests from being added to a specific group
Learn how to prevent guests from being added to a specific group
In this script, Once I run this script and when I going to run script second time to revert changes - I am getting below error - attached.

I tested this in two different tenant and same error***
Script-
Connect-MgGraph
$GroupName = ""
$templateId = (Get-MgBetaDirectorySettingTemplate | ? {$_.displayname -eq "group.unified.guest"}).Id
$groupID = (Get-MgBetaGroup -Filter "DisplayName eq '$GroupName'").Id
$params = @{
templateId = "$templateId"
values = @(
@{
name = "AllowToAddGuests"
value = "true"
}
)
}
New-MgBetaGroupSetting -GroupId $groupID -BodyParameter $params
Module Version
Script 1.0.0.0 ISE {Get-IseSnippet, Import-IseSnippet, New-IseSnippet}
Script 2.15.0 Microsoft.Graph.Authentication {Add-MgEnvironment, Connect-MgGraph, Disconnect-MgGraph, Get-MgContext...}
Script 2.15.0 Microsoft.Graph.Beta.Groups {Add-MgBetaGroupDriveListContentTypeCopy, Add-MgBetaGroupDriveListContentTypeCopyFromContentTypeHub, Add-MgBeta...
Script 2.15.0 Microsoft.Graph.Beta.Identity.Di... {Add-MgBetaTenantRelationshipManagedTenantAlertUserInputLog, Add-MgBetaTenantRelationshipManagedTenantManagemen...
Manifest 3.1.0.0 Microsoft.PowerShell.Management {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}
Manifest 3.0.0.0 Microsoft.PowerShell.Security {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl, Get-AuthenticodeSignature...}
Manifest 3.1.0.0 Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Script 4.9.1 MicrosoftTeams {Add-TeamChannelUser, Add-TeamUser, Connect-MicrosoftTeams, Disconnect-MicrosoftTeams...}
Environment Data
PSVersion 5.1.22000.2713
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.22000.2713
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Screenshots
The text was updated successfully, but these errors were encountered: