PowerShell for Windows Admins

Jan 25 2011   2:08PM GMT

System Restore Points pt 2



Posted by: Richard Siddaway
Tags:
Operating System
PowerShell v2

 

We have seen how to discover the available restore points.  What about creating one.

001
002
003
004
005
006
007
008
009
010
011
012
013
function new-systemrestorepoint {
[CmdletBinding()]
param ( 
[string]$computername=“.”,
[string]$description=“Testing123″
) $test = Test-Connection -ComputerName $computername -Count 1
if (-not ($test)){Throw “Computer $computername not reachable”

}

 $sr = [wmiclass]“\\$computername\root\default:SystemRestore”
 $sr.CreateRestorePoint($description, 0, 100)
}

 

 

 

 

We need to use [wmiclass] to create a new instance of the SystemRestore class. We can then use the CreateRestorePoint method with the description we’ve input as a parameter. The other paarmeters define it as an application install and begin system change respectively. This are generic enough to be left as is.  They can be made parameters if required

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: