Scripting examples > Job control scripts > Viewing and setting job and server options

Viewing and setting job and server options

The following sample script will gather and set several Double-Take job and server options. You may want to consider running cmdlets like this from the PowerShell command line, rather than a script, so you can see the values returned from the get cmdlets and then make appropriate adjustments for your set cmdlets. You will need to modify this script to fit your environment and configuration. The options used in this script are examples. You can get and set any option. See Server and job settings for a complete list of options.

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

 

# Sample script to gather and set Double-Take job and server options

# You may want to run these cmdlets from the PowerShell command prompt

# so that you can see the values returned for each of the get cmdlets

# and then determine appropriate desired values for each option

 

# Specify the variables to be used in the script

 

     # Source server and credentials

     $DtSourceName = "alpha"

     $DtSourceUserName = "domain\administrator"

     $DtSourcePassword = "password"

 

     # Target server and credentials

     $DtTargetName = "beta"

     $DtTargetUserName = "domain\administrator"

     $DtTargetPassword = "password"

 

# 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 $DtSourceName -UserName $DtSourceUserName -Password $DtSourcePassword

$DtTarget = New-DtServer -Name $DtTargetName -UserName $DtTargetUserName -Password $DtTargetPassword

 

# Gather and display several job and server settings

# These options are examples. You can get and set any option.

$DtMaxChecksumBlocksSource = Get-DtOption -ServiceHost $DtSource -Name MaxChecksumBlocks

$DtMaxChecksumBlocksTarget = Get-DtOption -ServiceHost $DtTarget -Name MaxChecksumBlocks

$DtMirrorChunkSizeSource = Get-DtOption -ServiceHost $DtSource -Name MirrorChunkSize

$DtMirrorChunkSizeTarget = Get-DtOption -ServiceHost $DtTarget -Name MirrorChunkSize

$DtCalculateByVolumeSource = Get-DtOption -ServiceHost $DtSource -Name CalculateByVolume

$DtCalculateByVolumeTarget = Get-DtOption -ServiceHost $DtTarget -Name CalculateByVolume

$DtAutoRemirrorSource = Get-DtOption -ServiceHost $DtSource -Name AutoRemirror

$DtAutoRemirrorTarget = Get-DtOption -ServiceHost $DtTarget -Name AutoRemirror

write-output "=================="

write-output "These are the current options and values."

write-output "The source is displayed first, and the target is displayed second."

$DtMaxChecksumBlocksSource

$DtMaxChecksumBlocksTarget

$DtMirrorChunkSizeSource

$DtMirrorChunkSizeTarget

$DtCalculateByVolumeSource

$DtCalculateByVolumeTarget

$DtAutoRemirrorSource

$DtAutoRemirrorTarget

 

# Store the desired value for each job and server setting

$DtMaxChecksumBlocksDesiredValue = @{MaxChecksumBlocks=64}

$DtMirrorChunkSizeDesiredValue = @{MirrorChunkSize=131072}

$DtCalculateByVolumeDesiredValue = @{CalculateByVolume=1}

$DtAutoRemirrorDesiredValue = @{AutoRemirror=1}

 

# Set the new values

Set-DtOption -ServiceHost $DtSource -Setting $DtMaxChecksumBlocksDesiredValue

Set-DtOption -ServiceHost $DtTarget -Setting $DtMaxChecksumBlocksDesiredValue

Set-DtOption -ServiceHost $DtSource -Setting $DtMirrorChunkSizeDesiredValue

Set-DtOption -ServiceHost $DtTarget -Setting $DtMirrorChunkSizeDesiredValue

Set-DtOption -ServiceHost $DtSource -Setting $DtCalculateByVolumeDesiredValue

Set-DtOption -ServiceHost $DtTarget -Setting $DtCalculateByVolumeDesiredValue

Set-DtOption -ServiceHost $DtSource -Setting $DtAutoRemirrorDesiredValue

Set-DtOption -ServiceHost $DtTarget -Setting $DtAutoRemirrorDesiredValue

 

# Regather and display the updated values

$DtMaxChecksumBlocksSource = Get-DtOption -ServiceHost $DtSource -Name MaxChecksumBlocks

$DtMaxChecksumBlocksTarget = Get-DtOption -ServiceHost $DtTarget -Name MaxChecksumBlocks

$DtMirrorChunkSizeSource = Get-DtOption -ServiceHost $DtSource -Name MirrorChunkSize

$DtMirrorChunkSizeTarget = Get-DtOption -ServiceHost $DtTarget -Name MirrorChunkSize

$DtCalculateByVolumeSource = Get-DtOption -ServiceHost $DtSource -Name CalculateByVolume

$DtCalculateByVolumeTarget = Get-DtOption -ServiceHost $DtTarget -Name CalculateByVolume

$DtAutoRemirrorSource = Get-DtOption -ServiceHost $DtSource -Name AutoRemirror

$DtAutoRemirrorTarget = Get-DtOption -ServiceHost $DtTarget -Name AutoRemirror

write-output " "

write-output "=================="

write-output "These are the updated options and values."

write-output "The source is displayed first, and the target is displayed second."

$DtMaxChecksumBlocksSource

$DtMaxChecksumBlocksTarget

$DtMirrorChunkSizeSource

$DtMirrorChunkSizeTarget

$DtCalculateByVolumeSource

$DtCalculateByVolumeTarget

$DtAutoRemirrorSource

$DtAutoRemirrorTarget

 

# 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.