You can call this operation to run a PowerShell, or bat command on one or more cloud desktops.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes RunCommand

The operation that you want to perform. Set the value to RunCommand.

CommandContent String Yes ZWNobyAxMjM=

The plaintext or Base64-encoded content of the command.

The Base64-encoded command content cannot exceed 16 KB in size.

DesktopId.N RepeatList Yes ecd-7w78ozhjcwa3u****

The ID of cloud desktop N. Valid values of N: 1 to 50.

If multiple cloud desktops are specified and the command succeeds on one or more of these cloud desktops, the call is successful. If multiple cloud desktops are specified and the command fails on all of these cloud desktops, you must re-specify this parameter.

RegionId String Yes cn-hangzhou

The ID of the region.

Type String Yes RunPowerShellScript

The language type of the command. Valid values:

  • RunBatScript
  • RunPowerShellScript
Timeout Long No 3600

The timeout period for the command to run. Unit: seconds. Default value: 60.

A timeout error occurs when the command cannot be executed because the process slows down or because a specific module or the Cloud Assistant client does not exist. When a timeout error occurs, the command process is forcibly terminated.

ContentEncoding String No Base64

The encoding mode of the command content. Valid values:

  • PlainText: The command content is not encoded and is transmitted in plaintext.
  • Base64: The command content is encoded in Base64.

Default value: PlainText. If the specified value of this parameter is invalid, PlainText is used by default.

Response parameters

Parameter Type Example Description
InvokeId String t-7d2a745b412b4601b2d47f6a768d****

The ID of the command execution.

RequestId String 473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

The ID of the request.

Examples

Sample requests

https://ecd.cn-hangzhou.aliyuncs.com/?Action=RunCommand
&CommandContent=ZWNobyAxMjM=
&DesktopId.1=ecd-7w78ozhjcwa3u****
&RegionId=cn-hangzhou
&Type=RunPowerShellScript
&<Common request parameters>

Sample success responses

XML format

<RunCommandResponse>
      <RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E</RequestId>
      <InvokeId>t-7d2a745b412b4601b2d47f6a768d****</InvokeId>
</RunCommandResponse>

JSON format

{
    "RequestId":"473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E",
    "InvokeId":"t-7d2a745b412b4601b2d47f6a768d****"
}

Error codes

For a list of error codes, visit the API Error Center.