Saturday, December 28, 2013

Backup Windows 8.1

Here is a short little PowerShell Function that I use to create a scheduled job that runs every night at midnight that backups my C:\ drive to my E:\ drive.

The code used to backup Windows 8.1:
wbAdmin start backup -backupTarget:E: -include:C: -quiet

Function Create-ScheduledJob {
<#
.Synopsis
   schedules nightly backups.
.FUNCTIONALITY
   PowerShell v3.0+
#>
[CmdletBinding()]
    Param( [Parameter( Mandatory = $True )]
           $JobName,
           [Parameter( Mandatory = $True )]
           $ScriptToRun,
           $VerbosePreference = "Continue" )

Begin{ $Trigger = (New-JobTrigger -Daily -At 12:01AM) }

Process{ Register-ScheduledJob -Name $JobName -Trigger $Trigger -ScriptBlock { "& wbAdmin start backup -backupTarget:E: -include:C: -quiet" } }

End { Write-Verbose "Your new ScheduledJob has been created successfully!" }

}Create-ScheduledJob