---
title: Back up and restore Office 365 settings
slug: access-guide/back-up-and-restore-office-365-settings
docTags: 
createdAt: 2026-10-09T06:41:08.044Z
---

## Back up Office 365 settings

- Open the PowerShell command window and enter the following command to connect to the Office 365 tenant:

PS C:\Connect-MgGraph -Scopes "Domain.ReadWrite.All Directory.AccessAsUser.All"

- Enter the following command to back up the current domain federation settings into a file:

PS C:\Get-MgDomainFederationConfiguration -DomainId \<federated-domain> | Export-Clixml \<xml-file-path>

For example:

Enter the following command to back up the current domain federation setting for the federated domain *orange.com* to an xml file *c:\orange.com-original-settings.xml.*

PS C:\Get-MgDomainFederationConfiguration -DomainId orange.com | Export-Clixml orange.com-original-settings.xml

## Restore Office 365 settings

Perform the following tasks to restore Office 365 settings from an existing saved file:

**Procedure**

1. Load the configuration into a variable.

:::Paragraph{indent="1"}
PS C:\\$original = Import-Clixml \<xml-file-path>
:::

:::Paragraph{indent="1"}
For example:
:::

:::Paragraph{indent="1"}
load config from file *c:\orange.com-original-settings.xml* into variable $original
:::

:::Paragraph{indent="1"}
PS C:\\$original = Import-Clixml orange.com-original-settings.xml
:::

2. Enter the following command to unfederate the domain if the domain is federated.

:::Paragraph{indent="1"}
PS C:\Update-MgDomain -DomainId \<federated-domain> -AuthenticationType "Managed"
:::

:::Paragraph{indent="1"}
For example: unfederate the *orange.com* domain
:::

:::Paragraph{indent="1"}
PS C:\Update-MgDomain -DomainId orange.com -AuthenticationType "Managed"
:::

:::hint{type="info" indent="1"}
Please wait for 1 minute after this command before proceeding to the next step.
:::

3. Enter the following command to restore the configuration from the variable.

:::Paragraph{indent="1"}
Check if the values used in this command are present in the xml file. Values which are not present in the xml file can be removed from the command.
:::

:::Paragraph{indent="1"}
FederatedIdpMfaBehavior argument is mandatory, so if it is not present in the xml file, you can use the value "acceptIfMfaDoneByFederatedIdp" for this argument.
:::

:::Paragraph{indent="1"}
PS C:\New-MgDomainFederationConfiguration -DomainId \<federated-domain> -DisplayName $original.DisplayName -IssuerUri $original.IssuerUri -PassiveSignInUri $original.PassiveSignInUri -ActiveSignInUri $original.ActiveSignInUri -SignOutUri $original.SignOutUri -SigningCertificate $original.SigningCertificate -PreferredAuthenticationProtocol $original.PreferredAuthenticationProtocol -FederatedIdpMfaBehavior $original.FederatedIdpMfaBehavior -MetadataExchangeUri $original.MetadataExchangeUri
:::
