IF-ELSE-STEP CommandsThe following is a summary of standard IF-ELSE-STEP commands used in VSA agent procedures.
IF Commands Application is Running Checks to see if a specified application is currently running on the managed machine. If the application is running, the IF command is executed; otherwise, the ELSE command is executed. When this option is selected from the drop-down list, the Enter the application name field appears. Specify the process name for the application you want to test. For example, to test the Check Registry Value / Check 64-Bit Registry Value After entering the registry path, the value contained in the key is returned. A check can be made for existence, absence, equality, or size differences. For example, A backslash character The available tests are:
Check Variable Enter a variable name, in the form
For the tests Evaluate Expression Enter an expression containing one or more variable names, in the form
Memory check - Total RAM Evaluates the total amount of memory reported by the latest audit of the agent. This could come in helpful in ensuring a system meets the resource requirements of an application before an installation is attempted. Operating systems supported: Windows, OS X, Linux Service is Running Determines if a service is running on the managed machine. Specify the service name.
Test File Determines if a file exists on a managed machine. Enter the full path and file name. Test File compares the full path and file name with the supplied value. If the check is true, IF commands are executed. If the check is false, ELSE steps are executed. Note: Environment variables such as The available tests are:
Test File in Directory Path Tests the specified file located at the path returned using the Get Directory Path From Registry step. The available tests are:
Test Registry Key / Test 64-bit Register Key Tests for the existence of a registry key. Test Registry Key differs from Check Registry Value since it can check for a directory level registry entry that only contains more registry keys (no values). True Selecting User Activity Check Determines whether the user is either:
Operating systems supported: Windows, OS X, Linux User Is Logged In Tests to see if a specific user or any user is logged on the managed machine. Enter the machine user's logon name or leave the field blank to check for any user logged on. The IF commands are executed if a user is logged on. The ELSE steps are executed if the user is not logged on. User Response is Yes Displays a dialog box on the managed machine with Yes and No buttons. Also carries out the ELSE command if a specified amount of time has timed out. If Yes is selected by the machine user, the IF command is executed. If the selection times out or the machine user selects No, the ELSE command is executed. This function requests the machine user's permission to proceed with the agent procedure. This query is useful for agent procedures that require a reboot of the managed machine before completion. Procedure variables, for example Windows 32 or 64 Bit Check Determines if the current Windows OS is 32 or 64-bit. Operating systems supported: Windows STEP Commands Capture Desktop Screenshot Captures a desktop screenshot of the agent machine and uploads it to the Kserver. The screenshot is saved as a PNG file with a unique name in a folder dedicated to that agent. You can access these files from the Agent > Documents page or from Live Connect. End-user notification options must be selected based on the level of user notification desired, silently capturing a screenshot, notifying the user that the capture will take place, or asking to approve the capture. A custom message can be entered if end-user notification or permission requesting is selected. Otherwise a standard message displays. Operating systems supported: Windows, OS X Change Domain User Group (Run on Domain Controller) Changes a domain user's membership in a domain user group. This STEP must be run on a domain controller. Enter the domain username of the member being added or removed from the domain user group. Then select whether to add or remove membership. Then select the domain user group. Operating systems supported: Windows Change Local User Group Changes a local user's membership in a local user group. Enter the local username of the member being added or removed from the local user group. Then select whether to add or remove membership. Then select the group. Operating systems supported: Windows Close Application If the specified application is running on the managed machine, then that application is closed down. Specify the process name for the application you want to close. For example, to close the Copy File Copies a file from one directory to another on the agent machine. If the target file exists, you must check a box to overwrite an existing file. Be sure to keep in mind folder syntax when running this STEP across different operating systems, for example, Operating systems supported: Windows, OS X, Linux Copy File – Use Credentials Copies a file from a directory on a machine and attempts to copy the file to a target directory and filename. The copy process uses either:
This STEP is mostly used for accessing files across network UNC shares. If the target file exists, you must check a box to overwrite an existing file. Be sure to keep in mind folder syntax when running this STEP across different operating systems, for example, Operating systems supported: Windows, OS X, Linux Create Domain User (run on Domain Controller) Adds a new user to an Active Directory domain when run on a domain controller. Enter a domain user name to create, then a password that meets the domain's complexity requirements for user accounts, then select the domain group the user will be added to, either Operating systems supported: Windows Create Event Log Entry Creates an event log entry in either the Application, Security or System event log types. You can create a Warning, Error or Informational event with your own description. The created event is hard-coded to use an Event ID of 607. Operating systems supported: Windows Create Local User Adds a new local user account to a machine. Enter a local user name to create, then a password that meets local user account complexity requirements, then select the group the user will be added to. Operating systems supported: Windows, OS X, Linux Create Windows File Share Creates a new file share on a Windows machine. You must type in the name of the file share as it will be accessed over the network, and enter the source folder on the agent for the file share. This folder will be created if it does not yet exist. Operating systems supported: Windows Delete Directory Deletes a directory from an agent machine. Ensure you have your directory syntax correct for Windows vs. OS X/ Linux. To ensure all sub-directories and files are also removed, check the Recursively delete subdirectories and files checkbox. Operating systems supported: Windows, OS X, Linux Delete File Deletes a file on a managed machine. Enter the full path and filename. Note: Environment variables are acceptable if they are set on a user's machine. For example, using a path Note: You can delete a file that is currently in use using the Rename Locked File command. Delete File in Directory Path Deletes the specified file located at the path returned using the Get Directory Path From Registry command. Delete Registry Key / Delete 64-bit Registry Key Deletes the specified registry key and all its sub-keys. Delete Registry Value / Delete 64-bit Registry Value Deletes the value stored at the specified registry key. Delete User Deletes a user from the agent machine. Operating systems supported: Windows, OS X, Linux Disable User Disables a user, preventing logon to the agent machine. Operating systems supported: Windows, OS X, Linux Disable Windows Service Disables a Windows service. Operating systems supported: Windows Enable User Enables a previously disabled user, allowing the user to logon to the OS. Operating systems supported: Windows, OS X Execute File Executes the specified file on the managed machine. This function replicates launching an application using the Run… command located in the Microsoft Windows Start menu. This function takes three parameters:
If Execute as the logged on user is selected, then a credential must be specified by running either the Impersonate User or Use Credential command before this command. If run Execute as the system account is selected, execution is restricted to the agent's system level access. Execute File in Directory Path Same as Execute File except the location of the .exe file is located at the path returned from a Get Directory Path From Registry command. If Execute as the logged on user is selected, then a credential must be specified by running either the Impersonate User or Use Credential command before this command. If run Execute as the system account is selected, execution is restricted to the agent's system level access. Execute Powershell Executes a powershell script, including:
Operating systems supported: Windows XP SP3+/Server 2008 with Powershell add-on, Windows 7, Windows Server 2008 Execute Procedure Causes another named procedure to execute. Use this capability to string multiple IF-ELSE-STEP procedures together. If the procedure no longer exists on the KServer, an error message displays next to the procedure drop-down list. You can use this command to run a system procedure. You can nest procedures to 10 levels. Execute Shell Command Allows the procedure to pass commands to the command interpreter on the managed machine. When this command is selected, the field Enter the command to execute in a command shell is displayed. Enter a command in the field. The command must be syntactically correct and executable with the OS version on the managed machine. Commands and parameters containing spaces should be surrounded by quotes. Since the command is executed relative to the agent directory, absolute paths should be used when entering commands. Note: Execute Shell Command opens a command prompt window on the managed machine to execute in. If you do not want a window opening on the managed machine, because it might confuse users, put all the commands in a batch file. Send that file to the managed machine using the Write File command. Then run the batch file with the Execute File command. Execute File does not open a window on the managed machine. If Execute as the logged on user is selected, then a credential must be specified by running either the Impersonate User or Use Credential command before this command. If run Execute as the system account is selected, execution is restricted to the agent's system level access. Execute Shell Command - Get Results to Variable Executes a shell command and returns output created during and after its execution to a variable. The variable must be referred to in subsequent steps as Operating systems supported: Windows, Linux, OS X Execute VBScript Runs a Vbscript, with or without command line arguments. If the Vbscript displays a popup window or notifies the end user, check the box for Use Wscript instead of Cscript. Operating systems supported: Windows Get Directory Path From Registry Returns a file path stored in the specified registry key. Use this command to fetch the file location. For instance, use this command to find the directory where an application has been installed. The result can be used in subsequent steps by:
Get File Upload the file at the specified path from the managed machine. Be sure to enter a full path filename that you want to upload. Example:
Get File in Directory Path Just like the Get File command but it adds the path returned from the Get Directory Path From Registry command to the beginning of the remote file path. Access the uploaded file using the Agent Procedures > Get File function. Get URL Returns the text and HTML contents of a URL and stores it to a file on the managed machine. To demonstrate this to yourself, try specifying Another use is to download an executable file that is available from a web server, so that you don't need to upload the file to the VSA server nor use the VSA's bandwidth to write the file down to each agent. You can use a subsequent command to run the downloaded executable on the managed machine. Get URL (Use Patch File Source Setting) Downloads a file from a given URL to a target folder and file for that agent. Uses the Patch Management > File Source settings. Operating systems supported: Windows Get Variable Defines a new agent variable. When the procedure step executes, the system defines a new variable and assigns it a value based on data fetched from the managed machine's agent. Note: See Using Variables for the types of variable values supported by the Get Variable command. Get Variable - Random Number Generates a random number which can then be accessed as the variable Operating systems supported: Windows, OS X, Linux Get Variable - Universal - Create Gets a variable that persists outside of the immediate procedure's execution. This can be useful for passing a variable to another agent procedure using the Schedule Procedure step. You can create up to three variables. You can enter either string data or variables created in an earlier step. Variables created using this step can only be read using the Get Variable – Universal – Read step in any subsequent step. Operating systems supported: Windows, OS X, Linux Get Variable - Universal - Read Reads up to three variables you have previously created using the Get Variable – Universal – Create step. These variables must be referred to as Operating systems supported: Windows, OS X, Linux Give current user admin rights Adds the current user to the local administrator’s group on the agent machine, either permanently or for a temporary period of time. This change does not take effect until the user logs off. It is recommended you leverage the Log off Current User step. Operating systems supported: Windows Impersonate User Enter a username, password, and domain for the agent to logon with. This command is used in a procedure before an Execute File, Execute File in Directory Path or Execute Shell Command that specifies the Execute as the logged on user option. Leave the domain blank to log into an account on the local machine. Use Impersonate User to run an agent procedure using a credential specified by agent procedure. Use Use Credential to run an agent procedure using a credential specified by managed machine. Install Apt-Get Package (Linux) Silently installs a package using the Operating systems supported: Linux Install Deb Package (Linux) Silently installs a Debian package on any Linux OS that supports Operating systems supported: Linux Install DMG (OS X) Silently installs a Operating systems supported: OS X Install MSI Installs an MSI file for Windows. Options can be selected to either run a quiet installation or to avoid automatically restarting the computer after installation if it is requested. Operating systems supported: Windows Install PKG (OS X) Silently installs a Operating systems supported: OS X Install RPM (Linux) Silently installs an RPM package on any Linux OS that supports installing RPMs. Operating systems supported: Linux Log off Current User Automatically logs off the current user. An optional warning that the log-off process is about to begin can be entered and displayed to the end-user. Operating systems supported: Windows, OS X Pause Procedure Pause the procedure for N seconds. Use this command to give Windows time to complete an asynchronous task, like starting or stopping a service. Reboot Unconditionally reboots the managed machine. To warn the user first, use the User Response is Yes command before this command. A User Response is Yes command prompts the user before rebooting their machine. Reboot with warning message Reboots a machine, displaying a warning message to the end-user before the reboot process occurs. Operating systems supported: Windows, OS X Remove Windows File Share Removes a file share from a Windows agent. Operating systems supported: Windows Rename Locked File Renames a file that is currently in use. The file is renamed the next time the system is rebooted. The specified filename is a complete file path name. Can be used to delete a file that is currently in use if the "new file name" is left blank. The file is deleted when the system is rebooted. Rename Locked File in Directory Path Renames a file that is currently in use that is located in the path returned from a Get Directory Path From Registry command. The file is renamed the next time the system is rebooted. Can be used to delete a file that is currently in use if the "new file name" is left blank. The file is deleted when the system is rebooted. Schedule Procedure Schedules a procedure to run on a specified machine. Optionally specifies the time to wait after executing this step before running the procedure and the specified machine ID to run the procedure on. If no machine is specified, then the procedure is run on the same machine running the agent procedure. Enter the complete name of the machine, for example, Send Email Sends an email to one or more recipients. Specifies the subject and body text of the email. Send Message Sends the entered message to a managed machine. An additional checkbox, if checked, sends the message immediately. If unchecked, sends the message after the user clicks the flashing agent system tray icon. Send URL Displays the entered URL in a web browser window on the managed machine. An additional checkbox, if checked, displays the URL immediately. If unchecked, the URL is displayed after the user clicks the flashing agent system tray icon. Set Registry Value / Set 64-bit Registry Value Writes data to the specified registry value. This function takes three parameters:
Start Windows Service Runs a Start command for a Windows service, if it exists. Operating systems supported: Windows Stop Windows Service Runs a Start command for a Windows service if it exists. Operating systems supported: Windows Transfer File Transfers a file from the agent machine running this step to another agent machine. Enter the fully qualified machine ID of the target machine, for example, Operating systems supported: Windows Uninstall by Product GUID Silently uninstalls a product based on its MSI GUID. Operating systems supported: Windows Unzip file Extracts the contents of a specified zip file to a target folder, with an option to automatically overwrite any previously existing target files or folders. Operating systems supported: Windows, OS X, Linux Update System Info Updates the selected System Info field with the specified value for the machine ID this procedure runs on. The System Info fields you can update include all columns in vSystemInfo except Use Credential Uses the credentials set for the machine ID in Set Credential. This command is used in a procedure before an Execute File, Execute File in Directory Path or Execute Shell Command that specifies the Execute as the logged on user option. Also used to access a network resource requiring a credential from a machine when a user is not logged on. Use Impersonate User to run an agent procedure using a credential specified by agent procedure. Use Use Credential to run an agent procedure using a credential specified by managed machine. Note: A procedure execution error is logged if a Set Credential procedure command encounters an empty username. Note: Patch Management > Patch Alert can alert you—or run an agent procedure—if a machine ID's credential is missing or invalid. Windows Service Recovery Settings Sets the Service Recovery Settings for any given service in Windows. Specify the name of the service you wish to modify, then set both the first and second restart failure options and any subsequent restart failure options. Operating systems supported: Windows Write Directory Writes a selected directory, including subdirectories and files, from Manage Files Stored on Server to the full path directory name specified on the managed machine. Write File Writes a file selected from Manage Files Stored on Server to the full path filename specified on the managed machine. Enter a new filename if you want the file to be renamed. Each time a procedure executes the Write File command, the agent checks to see if the file is already there or not by hashing the file to verify integrity. If not, the file is written. If the file is already there, the procedure moves to the next step. You can repeatedly run a procedure with Write File that sends a large file to a managed machine and know that the VSA only downloads that file once. Note: Environment variables are acceptable if they are set on a user's machine. For example, using the path Write File - From Agent Transfers a file from another agent machine to the agent machine running this step. Transfers a file between agents. Similar to the previous Transfer File step, though in this case you enter the fully qualified machine ID of the source machine that has the file you wish to send to the currently selected agent. First enter the full path and file name of the file you wish to send from the source machine. You then enter the full path and the file name to be created on the target machine. Operating systems supported: Windows Write File in Directory Path Writes the specified filename to the path returned from a Get Directory Path From Registry command. Write Procedure Log Entry Writes the supplied string to the Agent Procedure Log for the machine ID executing this agent procedure. Write text to file Writes text to a file on the agent machine, either by appending text to an existing file or by creating a new file if none exists. You enter the text to write to the file, then enter the full path and file name on the agent machine the text will be written to. You can optionally overwrite the entire file with the text you have entered if the file already exists. Operating systems supported: Windows, OS X, Linux Zip Directory Compresses a directory and any subdirectories or files it contains into a zip file on the agent machine. Enter the full path to be compressed, which can contain wildcards. Then enter the full path and file name of the zip file to be created or updated. If the target zip file already exists, optionally check a box to overwrite it. Operating systems supported: Windows, OS X, Linux Zip File(s) Compresses a single file or files into a zip file on the agent machine. Enter the full path of the file or files to be compressed. Then enter the full path and filename of the zip file to be created or updated. If the target zip already exists, optionally check a box to overwrite it. Operating systems supported: Windows, OS X, Linux | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Topic 674: Send Feedback. Download a PDF of this online book from the first topic in the table of contents. Print this topic. |