PowerShell 2.0: One Cmdlet at a Time 25 Restore-Computer

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Restore-Computer cmdlet.

What can I do with it?

Run a system restore on the local machine.

Example:

Restore the local computer to restore point 101 and then use the Restart-Computer cmdlet to reboot it

Restore-Computer -RestorePoint 101 Restart-Computer

How could I have done this in PowerShell 1.0?

You could have used the SystemRestore WMI class and the Restore method. You could then use the Get-WMIObject cmdlet, the Win32_OperatingSystem class and the Reboot method to restart the machine.

$SystemRestore = [wmiclass]"\\.\root\default:systemrestore" $SystemRestore.Restore(“101”) (Get-WmiObject Win32_OperatingSystem).reboot()

1000 things 1% better!