Microsoft 365 DSC Introduction & procedure of Microsoft 365 DSC With this tool you can export your Microsoft 365 tenant as code. This code can then be backed up, customized or restored to another environment. This makes it possible to keep several environments congruent and enables you to automate and execute integrety checks regularly thanks to the programmatic style of Microsoft 365 DSC. Preparations You have to install the module and update the dependencies first. Administrator rights on Windows are required for this installation step. Install-Module Microsoft365DSC Update-M365DSCDependencies Download tenant configuration For downloading an existing tenant configuration you have to add the credentials to a variable. This variable is required as the export can sometimes take over 1 hour. During this time, the access token will have expired and must be requested again. It is suggested to use an account or identity with Global Admin permissions and MFA disabled. $Credential = Get-Credential You can compile the final export statement yourself. It is best to click together the PowerShell command via this website and define the required export values: https://export.microsoft365dsc.com. Export-M365DSCConfiguration -Components @() -Credential $Credential Apply existing configuration Importing is the same as exporting configurations. The access data for the tenant must be stored in a variable and configured without MFA. $Credential = Get-Credential First, the configuration is assembled from the PowerShell script with the credential data to a .mob file. .\M365TenantConfig.ps1 -Credential $Credential The .mob file is then applied to the environment using the standard DSC module.  Start-DscConfiguration -Path .\M365TenantConfig\ -Wait -Verbose -Force Known issues & solutions Problems with Graph Permissions This command is used to adjust the Entra ID authorizations on the Enterprise app. All delegated rights that are required for a complete export & import are added. Update-M365DSCAllowedGraphScopes -All -Type 'Update' -Environment 'Global' Problems with DSCConfiguration This statement activates WinRM for the upload of configurations, which is used for the PowerShell command Start-DSCConfiguration. winrm quickconfig Another possibility for problems regarding the upload could be the standard chunk size of the configuration of DSC. This can be increased with this PowerShell command. Set-Item -Path WSMan:\localhost\MaxEnvelopeSizeKb -Value 8192