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:
Cisco UCS Director Orchestrator automates complex tasks by organizing them into workflows. Once built and validated, these workflows perform the same way every time, no matter who runs the workflows. These tasks encompass a wide variety of supported Cisco and non-Cisco hardware and software data center components.
For more information about workflows, see Cisco UCS Director Orchestration Guide.
PowerShell commands are used for executing workflows on a target server. Cisco UCS Director offers the following two types of command tasks:
The Execute PowerShell Command Task can run PowerShell scripts only on a remote server. When a command is executed, PowerShell Agent opens a remote PowerShell connection (PSSession) to the target server. Scripts are then executed on the target server. The connection is closed once the execution is complete.
In certain scenarios, PowerShell cmdlets are not executable and the script fails. This failure occurs because opening the remote session (PSSession) does not provide a complete PowerShell interactive desktop capability. As a result, the scripts are run in an environment that is different from the native PowerShell Agent console. For example, some Windows Active Directory cmdlets cannot be executed under PSSession unless they are run from a device that has a specific Windows Active Directory role associated with it.
PowerShell scripts may also fail if your environment has a multi-hop delegation and you have not enabled the CredSSP protocol in your infrastructure. This failure occurs because the scripts that are executed remotely cannot connect to other Windows machines.
PowerShell Agent to be used for executing the script.
Target Server's credentials (IP address, username and password, and domain)
Commands or Scripts of up to 64 kb.
When you execute the workflow in Cisco UCS Director, you are prompted to enter the PowerShell Agent commands to run on a target server. Use a ";" to separate multiple commands (for example, Hostname; Get-Process). Cisco UCS Director runs the commands against the target server and displays the output as an XML string in a service request log window.
See Executing PowerShell Commands for detailed steps.
The Execute Native PowerShell Command Task creates a native PowerShell instance on a Windows machine and executes the scripts natively on the PowerShell Agent. As a result, the target scripts are not sent over a remote WinRM session for execution. They are run locally on the PowerShell Agent. This feature allows you to bypass the limitations encountered when the scripts are run in a PSSesion using the Execute PowerShell Command Task.
The Execute Native PowerShell Command task simulates the PowerShell Console on a Windows machine. As a result, the command runs natively in a PowerShell CLI session. All the functionality offered by the PowerShell console is available through this task.
Certain windows commands are not supported when the output format is set to JSON and as a result a task may fail. There are no issues if the output format is set to XML.
Run the following command to convert the output format to XML:
dir| ConvertTo-Xml -As String
The Write-Error cmdlet causes the task to fail because this cmdlet is not compatible with the one on the console.
Certain cmdlets, such as Enter-PSSession and Write-Error, require an interactive shell fail with the error message method not implemented. You can use Invoke-Command if the cmdlet Enter-PSSession fails.
See Executing PowerShell Commands for detailed steps.
Open a web browser and log on to Cisco UCS Director to execute the PowerShell commands.
The following example outlines how you can set up PowerShell Agent on a Windows server and run a test task.
Step 1 | Create a Microsoft Windows Server 2008 R2 or 2012 R2 VM. |
Step 2 | Make sure that the VM has the required .NET Framework and Windows PowerShell versions. |
Step 3 | Open a web browser and log on to Cisco UCS Director. |
Step 4 | Choose . |
Step 5 | On the Virtual Accounts page, click PowerShell Agents. |
Step 6 | Click Download Installer and install the PowerShell Agent. See Downloading Cisco UCS Director PowerShell Agent |
Step 7 | In Windows Firewall, open the port that has been configured for the PowerShell Agent (the default port is 43891). |
Step 8 | Open PowerShell and run the following commands:
Enable-PSRemoting -Force Set-Item WSMan:\localhost\Client\TrustedHosts -Value "*" -Force Restart-Service WinRM Set-ExecutionPolicy unrestricted -Force |
Step 9 | Log on to Cisco UCS Director again and run the Execute the PowerShell command. See Executing PowerShell Commands. |
The Execute Native PowerShell Command task helps you to execute PowerShell scripts on the PowerShell Agent server. This task overcomes the limitations of the some of the third party cmdlets, which might not execute in remote sessions.
Note | To run PowerShell scripts from a remote server, use the Execute PowerShell Command task. |
Though the Execute Native PowerShell Command task simulates the PowerShell Console on a Windows server to the closest extent possible, there are a few limitations:
The Write-Error cmdlet does not work similarly to the one on the PowerShell console. The Write-Error cmdlet causes the task to fail.
Method not implemented
As the Enter-PSSession cmdlet does not work for establishing remote sessions, the workaround is to use Invoke-Command.