search
top

How to Backup System State with PowerShell

As tweaker’s there is always changes needed to the system to make it run to our liking and there is always the risk that those changes will break and possible have major repercussions. That’s where restore points come into play. With PowerShell there is a way to use system restore points to backup and restore if an issue does arise.

This process assumes that system restore points are enabled and you have administrative privileges on your system. Restore points is only available with Windows XP and higher (Vista, 7) and not on servers.

First we need to create the restore point. Open a PowerShell session on your system and type the following.

PS C:\> Checkpoint-Computer -Description 'Before script execution'

The Get-ComputerRestorePoint cmdlet returns all the restore points available on your system. You could filter out your new restore point with Where-Object and search for the object.Description equals.

PS C:\> Get-ComputerRestorePoint


PS C:\> Get-ComputerRestorePoint | Where-Object { $_.Description -eq 'Before script execution' }

Now that we have our restore point we can revert to it Using the SequenceNumber using the Restore-Computer cmdlet. The sequence number can be retrieved by using the output of the Get-ComputerRestorePointwe ran earlier.

PS C:\> Restore-Computer 60 -WhatIf

We can also use a variable and combine the Get-ComputerRestorePoint with filter.

PS C:\> $seq = Get-ComputerRestorePoint | Where-Object { $_.Description -eq 'Before script execution' } | Select-Object -ExpandProperty SequenceNumber

PS C:\> Restore-Computer $id -WhatIf

Not so bad and all done at the power of the command line with PowerShell.

While there are no command line tools for deleting restore points, you can disable them using Windows PowerShell in an elevated session.

PS C:\> Disable-ComputerRestore "C:\"

When you need to re-enable it run:

PS C:\> Enable-ComputerRestore "C:\"

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

top