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

Creating a full server to ESX appliance job

The following sample script will create a simple full server to ESX appliance 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 to ESX appliance 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 appliance objects

$DtSource = New-DtUvraServer -Name alpha -UserName domain\administrator -Password password -Port 6325

$DtAppliance = New-DtUvraServer -Name beta -UserName root -Password password -Port 6325

 

# Create ESX host object using default port of 443

$VimTarget = New-DtUvraServer -Name gamma -Username root -Password password

$OtherServers = @($VimTarget)

 

# Get proxy and host information

$DtProxy = Get-DtProxiedServerInfo -ServiceHost $DtAppliance -Source $DtSource

$VmHost = Get-DtUvraVmHost -ServiceHost $DtAppliance -EsxHost $VimTarget -VCenter

 

# Get appliance server info

$DtApplianceServerInfo = Get-DtServerInfo -ServiceHost $DtAppliance

 

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

$DtJobOptions = Get-DtUvraRecommendedJobOptions -ServiceHost $DtAppliance -Source $DtSource -SourceInfo $DtProxy -TargetInfo $DtApplianceServerInfo -ApplianceHost $VmHost

 

# If you need to modify a job option, you could use a command similar to the following

# $DtJobOptions.JobOptions.VRAOptions.ReplicaVmInfo.DisplayName = "Replica_Name"

 

# Create the job

$DtJobGuidForUVRA = New-DtJob -ServiceHost $DtAppliance -Source $DtSource -OtherServers $OtherServers -JobType "UVRA" -JobOptions $DtJobOptions.JobOptions

 

# Start the job

Start-DtJob -ServiceHost $DtAppliance -JobId $DtJobGuidForUVRA

 

# Close the connections for the server objects

Disconnect-DtServer -ServiceHost $DtSource

Disconnect-DtServer -ServiceHost $DtAppliance

Disconnect-DtServer -ServiceHost $VimTarget

 

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.