Last active
March 21, 2020 17:10
-
-
Save mobernberger/034c9dea86e02512cd036647a355f0a2 to your computer and use it in GitHub Desktop.
With this script/commandlet you could block/allow external guests to specific Office 365 group
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Connect to Azure AD Powershell with the Preview Module: Install-Module AzureADPreview | |
#Search for specific group | |
$GroupID = get-unifiedgroup -Identity <Insert SMTP or Identity> | Select-Object -ExpandProperty ExternalDirectoryObjectId | |
#Check if there is already a specific group settings specified and delete it | |
$SettingID = Get-AzureADObjectSetting -TargetType Groups -TargetObjectID $GroupID | select-object -expandproperty ID | |
Remove-azureadobjectsetting -id $settingid -targettype Groups -TargetObjectID $GroupID | |
#Create a new setting with Guests disabled | |
$template = Get-AzureADDirectorySettingTemplate | Where-Object {$_.displayname -eq "group.unified.guest"} | |
$settingsCopy = $template.CreateDirectorySetting() | |
$settingsCopy["AllowToAddGuests"]=$False | |
New-AzureADObjectSetting -TargetType Groups -TargetObjectId $groupID -DirectorySetting $settingsCopy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment