KB labels


Ticket Product Version

Ticket Category

Ticket Assignee


Hot Fixes

Published Fixes
Your Arcserve Support User Profile
First Name:
Last Name:
email:
Phone:
Company:*
Customer Type:
Language:

Country:
Region:

Time zone:
Follow

arcserve-KB : How to use the CA XOsoft Powershell snap-in for non-interactive control of scenarios

Last Update: 2015-12-15 22:09:58 UTC

Document ID:    TEC475967
Tech Document
Title:  How to use the CA XOsoft Powershell snap-in for non-interactive control of scenarios.

Description:

This article describes how to utilize the Microsoft Powershell combined with the CA XOsoft / CA ARCserve RHA Powershell Snap-In to create a non-interactive script to control scenarios.

Solution:

*** Please note that this document assumes that the reader has past scripting experience and is familiar with the Microsoft Powershell interface. Please see the links in the reference section for more information.

There are 3 steps to this process:

  1. Create a Secure Password File

    • The first step in connecting to the Control Service without user interaction from the Powershell is to create a 'securestring' text file that contains an encrypted copy of the password for the user account that you are going to connect with. The password stored in this encrypted file is passed to the script alleviating the need for interactive authentication to Powershell.

  2. Create a Powershell Script

    • The Powershell Script will add the CA XOsoft/Ca ARCserve RHA Powershell cmdlets, specify the path the Secure Password File, specify the user name being used for authentication, and then execute the specific CA XOsoft/CA ARCserve RHA Powershell cmdlets.

  3. Create a Script to call the Powershell Script

    • Powershell cmdlets cannot be executed outside of Powershell. If you wanted to create an executable file which can be executed from a directory or on the Windows desktop, or if you wanted to schedule the execution of the Powershell Script from Windows Scheduler or within the User Defined Scripts properties of a CA XOsoft/ CA ARCserve RHA scenario, you will need to create a script which calls the Powershell script.
  1. Create a secure password file

    Install the CA XOsoft/CA ARCserve RHA Powershell component, or logon to a host which already has this component installed.

    1. Open the CA XOsoft Powershell Snap-in

      • Start -> Programs -> CA -> XOsoft -> Powershell

    2. Run the following command once:

      PS> read-host -assecurestring | convertfrom-securestring | out-file C:\securestring.txt


    3. After typing the command (above) and hitting <ENTER> the cursor will 'carriage return' to the next line and blink waiting for you to enter the value of the password to be used to authenticate using the non-interactive script.

    4. Type the password for the user account you are going to use in the non-interactive script, then hit <ENTER>.

      Note: the password will appear in asterisks '*'

    5. You should see file named 'Securestring.txt' on the root of C:\

      • You can use any location or naming convention you would like for this file. This file does have to remain on the host with the PowerShell snap-in installed for later access.

  2. Create the PowerShell Script

    1. Open a text file and populate it with the following commands:

    2. Path to the 'SecureString' file needs to match where it was created or where it was saved if it was moved.

      add-pssnapin XOpowershell
      $pass = cat C:\securestring.txt | convertto-securestring
      $mycred = new-object -typename System.Management.Automation.PSCredential -Argumentlist 'Domain\User Name',$pass

      connect-xo -host {control service host name|IP address} $mycred -protocol {Http|Https}

    3. Insert the CA XOsoft/Ca ARCserve RHA powershell commands at the bottom of the script.

    4. Save the Powershell Script with a name according to how you would like to reference it and the file extension '.ps1'.

      • Example: 'run_SQL.ps1':

        add-pssnapin XOpowershell
        $pass = cat C:\securestring.txt | convertto-securestring
        $mycred = new-object -typename System.Management.Automation.PSCredential -Argumentlist 'xolab\Administrator',$pass

        connect-xo -host xocontrol1 -protocol http $mycred

        run-scenario -Name 'SQL' -Mode B -ignore 0

      • Powershell Scripts MUST use the actual command, not the alias. When you launch the CA XOsoft/CA ARCserve RHA Powershell you will see a list of support cmdlets. The 'Definition' column shows the actual name, while the NAME column shows the 'Alias'. Do not use the Alias in a Powershell Script.

      • Use the 'get-Help' command along with the '-Detailed', and/or '-Full' switches.

  3. Create a Script Which Calls and Runs the PowerShell Script

    1. Open a text file and populate it with the following commands:

      C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -Noninteractive -command set-executionpolicy RemoteSigned; <path to .ps1 file>

    2. Replace '<path to .ps1 file>' with the specific the path to the .PS1 file.

    3. Save the file and name it accordingly.

    4. This script will be used when executing the Powershell script non-interactively outside of Powershell. This is the script which will be populated in Windows Scheduler, CA XOsoft/CA ARCserve RHA user defined scripts and other 3rd party applications, etc.

When this script is executed, it launches Powershell, then executes the Powershell commands from the *.ps1 file. The commands in the *.ps1 file will load the CA XOsoft/Ca ARCserve RHA cmdlets, then pass the user name which will be used for authentication. The password associated with the account in the .ps1 file will use the secure password stored in the Secure Password file to authenticate. Once Authentication is successfully completed, the CA XOsoft/CA ARCserve RHA Powershell cmdlets at the bottom of the *.ps1 file are executed.

Linked to this article are the following files within a ZIP file:

  1. UserSampleScript.bat - sample batch file for calling the PowerShell script

  2. UserSampleScript.ps1 - sample PowerShell script from above

  3. PS_Script_Command_List.txt - Base list of available commands, use 'get-help <command> -full' for a list of options and descriptions of each.

  4. XO_POWER_W_ENU.pdf - CA XOsoft PowerShell operations guide.

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments