Scripting examples > Other sample scripts > Shutting down the Double-Take service on a server

Shutting down the Double-Take service on a server

The following sample script will login to a Double-Take server and then shutdown the Double-Take service on that server. 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 shutdown the Double-Take service on a server

 

# Specify the variables to be used in the script

 

     # Source server and credentials

     $DtSourceName = "alpha"

     $DtSourceUserName = "domain\administrator"

     $DtSourcePassword = "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 object

$DtSource = New-DtServer -Name $DtSourceName -UserName $DtSourceUserName -Password $DtSourcePassword

 

# Shutdown the Double-Take service on the server

Stop-DtReplicationService -ServiceHost $DtSource

 

# Close the connections for the server object

Disconnect-DtServer -ServiceHost $DtSource

 

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.