How to store Exchange settings before making changes

When you modify settings within Exchange there’s always a chance you may need to examine what the values were originally set to – or prove what they were – before you made the change. Sometimes you may be changing unrelated information but wouldn’t it be handy if you could keep a snapshot of the configuration?

You can, using the Export-CliXml and Import-CliXml cmdlets. These allow you to export the object, or multiple objects as an XML file that you can re-import to the session to examine at a later date.

Let’s take a look at how we might do that if we were changing a user’s email address via the Exchange Management Shell and wanted to record the full results of Get-Mailbox for that user beforehand.

First, we’ll get the mailbox and use Export-CliXml to save it’s properties to an XML file:

Get-Mailbox steve.goodman | Export-Clixml .\Steve.Goodman.xml 

 

 

Figure 1

Next, we’ll change the Primary SMTP Address of the user:

Set-Mailbox steve.goodman -PrimarySmtpAddress [email protected] 

Image

Figure 2

Then we’ll examine our changes by having a quick look at the PrimarySMTPAddress and EmailAddresses properties:

Get-Mailbox steve.goodman | Format-List PrimarySmtpAddress,EmailAddresses 

 

 

Figure 3

Looks good. But if at a later date we were asked to confirm what the Primary SMTP Address and Email Addresses were beforehand – for example, if a user suspects one was erroneously removed, how could we accomplish that?

We’ll do that using Import-CliXml. This effectively allows us to retrieve our original Get-Mailbox command we piped to Export-CliXml, including all the properties that would have been available; therefore we can use the same approach used above to examine what the Primary SMTP Address and Email Addresses were:

Import-Clixml .\Steve.Goodman.xml | Format-List PrimarySmtpAddress,EmailAddresses 

Image

Figure 4

As you’ll see, the original values are displayed (with no changes being made to the current environment). If anything was removed we’ll be able to see and then manually re-add them. In this case we’ll be able to confirm no email addresses were erroneously removed.

You can use this approach for other purposes too apart from single mailboxes. For example, if you are about to make changes to the OWA Virtual Directories on multiple servers, you can use the following command to save the current configuration to a file:

Get-OwaVirtualDirectory | Export-Clixml .\OWAVirtualDirectories.xml

Or, if you were about to make multiple changes via Set-User to many users – such as UPN updates, you could use the following command:

Get-User -ResultSize Unlimited | Export-CliXml .\Users.xml

Remember, when using Import-CliXml to re-import the data, you can treat the input in a similar way to the results from running the original Get- command – so as assigning it to a variable and for multiple results, examining members:

Image

Figure 5

About The Author

Leave a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top