Automate SharePoint Online Organizational Settings

Iron Contributor

I wish to automate various aspects of Sharepoint Online including site level but also organization level settings like external sharing etc. I don't see how to do this with the Graph REST API nor the Sharepoint Online CMDLETS. Anyone give a steer on how to achieve this?

7 Replies
You could simply set the org-level and then control all containers (sites, groups and teams) with sensitivity labels for containers, which include sharing level and default sharing links etc.

https://learn.microsoft.com/en-us/microsoft-365/compliance/sensitivity-labels-teams-groups-sites?vie...

@shocko 

You could use "Microsoft 365 Desired State Configuration" for that

 

# Getting client credential
$Credential = Get-Credential

# Exporting resources using credentials
Export-M365DSCConfiguration -Components @("SPOAccessControlSettings", "SPOApp", "SPOBrowserIdleSignout", "SPOHomeSite", "SPOHubSite", "SPOOrgAssetsLibrary", "SPOPropertyBag", "SPOSearchManagedProperty", "SPOSearchResultSource", "SPOSharingSettings", "SPOSite", "SPOSiteAuditSettings", "SPOSiteDesign", "SPOSiteDesignRights", "SPOSiteGroup", "SPOSiteScript", "SPOStorageEntity", "SPOTenantCdnEnabled", "SPOTenantCdnPolicy", "SPOTenantSettings", "SPOTheme", "SPOUserProfileProperty") -Credential $Credential

 

Set as in manually? I'm looking to automate.
What API is it using for this?
Isn’t much work to toggle the org-wide setting once is it? Haven’t used Graph for adding labels to containers but there’s PowerShell too.

@shocko 

Internally they use the "Get-PnPTenant" Command from PnP Powershell.


https://github.com/microsoft/Microsoft365DSC/blob/Dev/Modules/Microsoft365DSC/DSCResources/MSFT_SPOS...

 

I am not 100% sure, but I assume they are using the CSOM Library in that command


https://github.com/pnp/powershell/blob/dev/src/Commands/Admin/GetTenant.cs

@shocko You should know, if not already understood, that we are talking about quite different things here. What @SvenSieverding are posting about are multiple settings, while I'm posting about the ability to control all external access and external sharing settings for sites using sensitivity labels. Your use case isn't clear and not sure what settings you want to configure.