Schedule-SystemState

# Setup variables
$server = $env:computername
$UNCpath = "\\$server\Backup" # Create a shared folder and put the full UNC path here

# Test that UNC Path is working
$PathTest = Test-Path $UNCpath
if ($PathTest -eq $True) {cls ; Write-Host -ForegroundColor Cyan "Good to go!"} else {cls ; Write-Warning "UNC path is not accessible" ; exit}

# Create a System State backup Scheduled Task
Set-Location $ENV:SystemRoot\System32
    $wbadmin = Test-Path .\wbadmin.exe
    if ($wbadmin -eq $True) {
    .\wbadmin.exe enable backup -addtarget:$UNCpath -schedule:02:00 -user:Administrator -password:P@ssw0rd1 -systemState -quiet 
    } 
    else {cls ; Write-Warning "Windows Backup is not properly installed" ; exit} 
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s