My mission on this page is to explain how to restore your computer’s system settings using two PowerShell commands, Restore-Computer and firstly, Get-ComputerRestorePoint
While you could do this via the Control Panel, I will show you how PowerShell can not only perform the restore, but also list the sequence numbers or restore points.
(Screenshot of Control Panel, System, Advanced Tab)
Topics for PowerShell Restore-Computer
- Restore-Computer – The Main Event
- Controlling Restore Points
Background on Restoring a Computer
In times of trouble a life-saver is the ability to turn back the clock to time when your computer was working fine. The other side of this coin is that if your Windows operating system is not broken, then I would use these PowerShell scripts to merely simulate a system restore using the -WhatIf parameter.
What a system restore does is replace changes to Windows files, programs, registry settings and scripts made by any user account. If a system restore does cure the configuration problem, then be reassured that the changes do not affect your personal files.
Let us begin by researching the options available. This PowerShell cmdlet will list the restore points. You can then decide which point-In-time you want to recovering the computer to its former state.
# PowerShell 2.0 and 3.0 List Restore Points
Sample results for Get-ComputerRestorePoint
CreationTime Description SequenceNumber RestorePointType
———— ———– ————– ——— —————-
14/02/2012 13:21:31 Windows Update 232 … 18
15/02/2012 13:00:17 Windows Update 233 … 18
16/02/2012 13:00:12 Windows Update 234 … 18
17/02/2012 18:52:50 Installed GuyApp 235
19/02/2012 14:09:51 Windows Update 236 … 18
21/02/2012 13:00:12 Windows Update 237 … 18
Note 1: It’s the sequence number that we are most interested in. Let us assume that GuyApp caused the problem, in which case we need to restore SequenceNumber 235 on the 17th of February 2012.
Note 2: You can see in passing how it was Windows Update that automatically created most of the restore points.
Note 3: I am ashamed to say that I cannot find out more information from Microsoft about RestorePointType values. 18 seems to mean a critical update.
SolarWinds’ Config Generator is a free tool, which puts you in charge of controlling changes to network routers and other SNMP devices. Boost your network performance by activating network device features you’ve already paid for.
Guy says that for newbies the biggest benefit of this free tool is that it will provide the impetus for you to learn more about configuring the SNMP service with its ‘Traps’ and ‘Communities’. Try Config Generator now – it’s free!
Get-Help and Get-Member
Here are two trusty techniques to discover more about Get-ComputerRestorePoint. Please apply these helpful commands to other PowerShell cmdlets such as Restore-Computer.
# Research Cmdlet Parameters
Get-Help Get-ComputerRestorePoint -full
This is how I found out a little more about parameters:
# Research Cmdlet Properties
Get-ComputerRestorePoint | Get-Member
Note 4: PowerShell’s signature tune, the pipe (|), is crucial here. Incidentally Get-Member is often abbreviated to GM.
Once you have the sequence number then you employ a different cmdlet to actually restore your computer’s settings to that point in time. Remember that System Restore returns your computer to the state immediately before the restore point that you chose.
More good news, system restore creates a restore point for itself, this is what enabled me to undo my action of restoring point 235.
# PowerShell 2.0 Restore the Windows operating system
Restore-Computer -RestorePoint 235 -WhatIf
Note 5: In this example I have deliberately appended -WhatIf, please remove this parameter when you are ready to restore your computer for real. Naturally your -RestorePoint number will be different from mine.
Note 6: If you have exhausted Microsoft’s restore point options, but have still not cured your problem then you have two main fall-back strategies. Trying to pin-point the symptoms then solve the specific fault, or to reinstall the Windows operating system from the original DVD / iso file, or from an image.
SolarWinds’ Network Performance Monitor will help you discover what’s happening on your network. This utility will also guide you through troubleshooting; the dashboard will indicate whether the root cause is a broken link, faulty equipment or resource overload.
What I like best is the way NPM suggests solutions to network problems. Its also has the ability to monitor the health of individual VMware virtual machines. If you are interested in troubleshooting, and creating network maps, then I recommend that you try NPM now.
Microsoft provides sister PowerShell cmdlets to manipulate the other aspects of restore points, for example, you may wish to temporarily disable the ability to create restore points if you are grappling with malware. In older systems with small system partitions you may want to stop creating restore points in order to conserver or reclaim disk space.
# PowerShell 2.0 Disable ComputerRestore Script
# Enable-ComputerRestore -drive "C:\"
Disable-ComputerRestore -drive "C:\"
Let us assume that you fixed the anti-virus predicament, or sorted the low disk space problem. Now it’s a straightforward task to reverse the above script by changing the Disable verb for Enable:
# PowerShell 2.0 Enable ComputerRestore Script
Enable-ComputerRestore -drive "C:\"
Summary of PowerShell Restore-Computer
This page covers how to restore a computer’s system settings using PowerShell commands, rather than the Control Panel. I recommend that you enumerate the restore points with Get-ComputerRestorePoints, then decide which point in time that you want to restore your computer using Restore-Computer.
If you like this page then please share it with your friends
See More Windows PowerShell Examples of Real-life Tasks
Please email me if you have a better example script. Also please report any factual mistakes, grammatical errors or broken links, I will be happy to correct the fault.