You are here: Scripting examples > Sample job creation scripts > Creating a full server job

Creating a full server job

The following sample script will create a simple full server job. You will need to modify this script to fit your environment and configuration.

Be sure and expand your screen wide enough so that lines in the script file do not wrap.

 

# Sample script to create a simple Double-Take full server job

 

# Import the Double-Take PowerShell module

# This may be \Service\ or \Console\ depending on your installation

import-module "C:\Program Files\Vision Solutions\Double-Take\Console\DoubleTake.PowerShell.dll"

 

# Create source and target objects

$DtSource = New-DtServer -Name alpha -UserName domain\administrator -Password password

$DtTarget = New-DtServer -Name beta -UserName domain\administrator -Password password

 

# Set the reserved IP address on the source and target servers

Set-DtOption $DtSource -Setting @{ReservedAddress="10.10.10.29"}

Set-DtOption $DtTarget -Setting @{ReservedAddress="10.10.10.30"}

 

# Create a workload

$DtWorkloadGUID = New-DtWorkload -ServiceHost $DtSource -WorkloadTypeName "FullServerFailover"

 

# Add what you want to protect to the workload

$DtLogicalItems = Get-DtLogicalItem -ServiceHost $DtSource -WorkloadId $DtWorkloadGUID

$DtProtectionItems = Set-DtLogicalItemSelection -ServiceHost $DtSource -WorkloadId $DtWorkloadGuid -LogicalPath $DtLogicalItems[0].Path

$DtWorkload = Get-DtWorkload -ServiceHost $DtSource -WorkloadId $DtWorkloadGUID

 

# Get the default options that will be used to create the job

$DtJobOptions = Get-DtRecommendedJobOptions -ServiceHost $DtTarget -Source $DtSource -JobType "FullServerFailover" -Workload $DtWorkload

 

# Specify the reserved addresses set earlier to be used in the job options to be used for reverse

$DtJobOptions.JobOptions.SystemStateOptions.SourceReservedAddress = $(Get-DtOption $DtSource ReservedAddress)["ReservedAddress"]

$DtJobOptions.JobOptions.SystemStateOptions.TargetReservedAddress = $(Get-DtOption $DtTarget ReservedAddress)["ReservedAddress"]

 

# Create the job

$DtJobGuidForFullServer = New-DtJob -ServiceHost $DtTarget -Source $DtSource -JobType "FullServerFailover" -Options $DtJobOptions.JobOptions

 

# Start the job

Start-DtJob -ServiceHost $DtTarget -JobId $DtjobGuidForFullServer

 

# Close the connections for the server objects

Disconnect-DtServer -ServiceHost $DtSource

Disconnect-DtServer -ServiceHost $DtTarget

If you want to hide your user credentials in your script, use the Windows PowerShell Get-Credential cmdlet. The password will not be visible because Windows stores an encrypted password. See Hiding your password in a PowerShell script for basic details on using this cmdlet. See your Windows PowerShell documentation for detailed instructions.