- #How to remove office 365 personal from share how to
- #How to remove office 365 personal from share registration
A generic method you can use for constructing web requests public void AllowToAddGuests(string groupId, bool allow, string accessToken) To keep this example simple enough, I’ll leave fetching the group id and access token to you.
Here we first create the request body, which is the setting template, and then make a POST request to Graph API.
#How to remove office 365 personal from share registration
If you have not yet set up an application registration in Azure AD for calling Microsoft Graph (required), check this blog post for instructions. # Get-UnifiedGroup -Identity $groupId | select Alias, AllowAddGuests # You can use this line to check if the setting has been successfully applied after a little while New-AzureADObjectSetting -TargetType Groups -TargetObjectId $groupId -DirectorySetting $setting $session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -Credential $cred -Authentication Basic -AllowRedirectionĬonnect-AzureAD -TenantId $tenantId -Credential $cred The last line of code is commented out because the change doesn’t come into effect immediately, but you can run the line separately after a few minutes to ensure that the setting has been applied. After successful authentication, a new setting template is created with the AllowToAddGuest value set to false, and the template is applied to the group. After that, when you run the script, you’ll be prompted for credentials to authenticate to both Exchange and Azure AD. Here you first need to provide the tenant id for connecting to Azure AD and the id of the group you want to restrict access for. go to Graph Explorer and make a GET request to (you simply need to paste that url to the query field and hit Run Query, nothing else). In case you want to see all the available templates, you can e.g. The template id is the same across all tenants. In both cases it can take a few minutes for the setting to be applied, so be patient when checking the result. There are two ways to add this setting template to an Office 365 Group: a PowerShell script or a request to Microsoft Graph API. To disable external sharing for a unified group, you need to add a setting template called to the group settings with “AllowToAddGuests” value set to false. Disabling External Sharing for an Office 365 Group
#How to remove office 365 personal from share how to
I have also got to work with those, and in this blog post, I’ll tell you how to programmatically disable external sharing for a single Office 365 Group and its SharePoint site. The Office 365 external sharing settings have been a hot topic in many conversations lately.