The documentation set for this product strives to use bias-free language. For the purposes of this documentation set, bias-free is defined as language that does not imply discrimination based on age, disability, gender, racial identity, ethnic identity, sexual orientation, socioeconomic status, and intersectionality. Exceptions may be present in the documentation due to language that is hardcoded in the user interfaces of the product software, language used based on RFP documentation, or language that is used by a referenced third-party product. Learn more about how Cisco is using Inclusive Language.
This chapter contains the following sections:
You can also execute commands on guest VMs using the Execute VM Command task available from the UCS Director task library. Execute VM Command allows you to perform guest OS operations by running commands through either PowerShell or the command prompt.
To run PowerShell commands, provide the following in the Command Path field in the Execute VM Command task:
To run commands through the command prompt, provide the following in the Execute VM Command task:
The path of cmd.exe in the Command Path field
The command along with arguments in the Command Arguments field
Note | The Execute VM Command task will be deprecated in a future release. The same functionality is available in the Guest Operations task. |
The following examples illustrate how you can execute Linux or Windows commands on a VM using the Execute VM Command task.
In this example, we execute a Windows command at PowerShell by using the Execute VM Command task. To execute a command at PowerShell, provide the path of PowerShell and the command.
Enter the following information in the Execute VM Command task available on the UCS Director appliance:
Select the VM where you want to execute the Windows command.
Enter the administrator credentials of the VM.
In the Command Path field, enter the path of PowerShell and the command:
C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\PowerShell.exe Get-NetAdapter | Where-Object {$_.Status -eq ‘UP’} | Set-DNSClientServerAddress -ServerAddresses ('${DNS1}','${DNS2}')
Note | Here DNS1 and DNS2 are defined workflow inputs. |
After executing the task, you see the following information in the SR log:
Service request ID: 734 Workflow Inputs: - DNS1 - DNS2 Apr 26, 2016 12:06:00 UTC Request Submitted Apr 26, 2016 12:06:03 UTC Executing workflow item number 1 Apr 26, 2016 12:06:03 UTC Completed workflow item number 0, with status completed Apr 26, 2016 12:06:09 UTC Executing workflow item number 2 Apr 26, 2016 12:06:00 UTC Trigger context executeWorkflowStep called Apr 26, 2016 12:06:09 UTC Executing custom action Execute_VM_Command(Execute VM Command) Apr 26, 2016 12:06:09 UTC Executing custom action Execute_VM_Command(Execute VM Command) Apr 26, 2016 12:06:13 UTC Task#1 (Execute_VM_Command(Execute VM Command)) completed successfully in 3 seconds Apr 26, 2016 12:06:13 UTC Input/Output values for Task#1 (Execute_VM_Command(Execute VM Command)): Apr 26, 2016 12:06:13 UTC [Local Input: Select VM = 3312) Apr 26, 2016 12:06:13 UTC [Local Input: Login = administrator] Apr 26, 2016 12:06:13 UTC [Local Input: Password = "masked-value") Apr 26, 2016 12:06:13 UTC [Template Input: Command Path = C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\PowerShell.exe Get-NetAdapter | Where-Object {$_.Status -eq ‘UP’} | Set-DNSClientServerAddress -ServerAddresses ('${DNS1}','${DNS2}')] Apr 26, 2016 12:06:13 UTC [Resolved Template Input: Command Path = C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\PowerShell.exe Get-NetAdapter | Where-Object {$_.Status -eq ‘UP’} | Set-DNSClientServerAddress -ServerAddresses ('10.10.10.10','20.20.20.20')] Apr 26, 2016 12:06:13 UTC [Local Input: Command Path = C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\PowerShell.exe Get-NetAdapter | Where-Object {$_.Status -eq ‘UP’} | Set-DNSClientServerAddress -ServerAddresses ('10.10.10.10','20.20.20.20')] Apr 26, 2016 12:06:13 UTC [Local Input: Command Arguments = ] Apr 26, 2016 12:06:13 UTC Completed workflow item number 1, with status completed Apr 26, 2016 12:06:13 UTC Completed workflow item number 3 Apr 26, 2016 12:06:13 UTC Completed workflow item number 2, with status completed
In this example, we execute a Windows command at Command prompt by using the Execute VM Command task. To execute a command at command prompt, provide the path of cmd.exe in the command path. Also provide the command and the comma-separated arguments in the Command Arguments field.
Enter the following information in the Execute VM Command task available on the UCS Director appliance:
Select the VM where you want to execute the Windows command.
Enter the administrator credentials of the VM.
In the Command Path field, enter the path of the cmd.exe file:
C:\\WINDOWS\\system32\\cmd.exe
In the Command Arguments field, enter the command and the comma-separated arguments:
mkdir C:\\testDir1,C:\\testDir2,C:\\testDir3
After executing the task, you see the following information in the SR log:
Service request ID: 534 Apr 06, 2016 12:06:00 UTC Request Submitted Apr 06, 2016 12:06:03 UTC Executing workflow item number 1 Apr 06, 2016 12:06:03 UTC Completed workflow item number 0, with status completed Apr 06, 2016 12:06:09 UTC Executing workflow item number 2 Apr 06, 2016 12:06:00 UTC Trigger context executeWorkflowStep called Apr 06, 2016 12:06:09 UTC Executing custom action Execute_VM_Command(Execute VM Command) Apr 06, 2016 12:06:09 UTC Executing custom action Execute_VM_Command(Execute VM Command) Apr 06, 2016 12:06:13 UTC Task#1 (Execute_VM_Command(Execute VM Command)) completed successfully in 3 seconds Apr 06, 2016 12:06:13 UTC Input/Output values for Task#1 (Execute_VM_Command(Execute VM Command)): Apr 06, 2016 12:06:13 UTC [Local Input: Select VM = 3312) Apr 06, 2016 12:06:13 UTC [Local Input: Login = administrator] Apr 06, 2016 12:06:13 UTC [Local Input: Password = "masked-value") Apr 06, 2016 12:06:13 UTC [Local Input: Command Path = C:\\WINDOWS\\system32\\cmd.exe] Apr 06, 2016 12:06:13 UTC [Local Input: Command Arguments = mkdir C:\\testDir1,C:\\testDir2,C:\\testDir3] Apr 06, 2016 12:06:13 UTC Completed workflow item number 1, with status completed Apr 06, 2016 12:06:13 UTC Completed workflow item number 3 Apr 06, 2016 12:06:13 UTC Completed workflow item number 2, with status completed
In this example, we execute a Linux command at Command prompt by using the Execute VM Command task.
Enter the following information in the Execute VM Command task available in the UCS Director appliance:
Select the VM where you want to run the Linux command.
Enter the administrator credentials of the VM.
In the Command Path field, enter the sample Linux command:
/bin/mkdir
In the Command Arguments field, enter the command:
/opt/testDirectory
After executing the task, you see the following information in the SR log:
Service request ID: 445 Apr 06, 2016 12:06:00 UTC Request Submitted Apr 06, 2016 12:06:03 UTC Executing workflow item number 1 Apr 06, 2016 12:06:03 UTC Completed workflow item number 0, with status completed Apr 06, 2016 12:06:09 UTC Executing workflow item number 2 Apr 06, 2016 12:06:00 UTC Trigger context executeWorkflowStep called Apr 06, 2016 12:06:09 UTC Executing custom action Execute_VM_Command(Execute VM Command) Apr 06, 2016 12:06:09 UTC Executing custom action Execute_VM_Command(Execute VM Command) Apr 06, 2016 12:06:13 UTC Task#1 (Execute_VM_Command(Execute VM Command)) completed successfully in 3 seconds Apr 06, 2016 12:06:13 UTC Input/Output values for Task#1 (Execute_VM_Command(Execute VM Command)): Apr 06, 2016 12:06:13 UTC [Local Input: Select VM = 2339) Apr 06, 2016 12:06:13 UTC [Local Input: Login = administrator] Apr 06, 2016 12:06:13 UTC [Local Input: Password = "masked-value") Apr 06, 2016 12:06:13 UTC [Local Input: Command Path = /bin/mkdir] Apr 06, 2016 12:06:13 UTC [Local Input: Command Arguments = mkdir /opt/testDirectory] Apr 06, 2016 12:06:13 UTC Completed workflow item number 1, with status completed Apr 06, 2016 12:06:13 UTC Completed workflow item number 3 Apr 06, 2016 12:06:13 UTC Completed workflow item number 2, with status completed