Script Management
Scenarios
On the console, the administrator can remotely run commands based on the created scripts to perform operations on cloud desktops.

By default, PowerShell script execution is prohibited on Windows desktops. You need to run commands to enable PowerShell script execution.
Procedure: Press Win + S on the cloud desktop and enter Windows PowerShell in the search box. Right-click Windows PowerShell in the search result, and choose Run as administrator from the shortcut menu. On the displayed CLI page, enter Set-ExecutionPolicy RemoteSigned, press Enter, and select y.
Prerequisites
You have obtained the script.
Constraints
The API for batch command execution has the following requirements on components:
WKSAppCenterAgent 1.2.16 or later
HW.SysAgent 24.8.30.19029 or later
Procedure
Creating a script
- Log in to the console.
- In the navigation pane, choose O&M > Script Management.
The Script Management page is displayed.
- Click Create Script in the upper right corner to go to the Create Script page.
- Configure the script.
- Script Name: name of the script to be created. The script name must be unique and cannot be empty.
- Execution Environment: Select Windows Script, Windows PowerShell, or Linux Shell.
- Description: Enter the description.
- Script Content: Enter the script content.
- Click OK.
Executing a script
- Select the script to be executed in the script list.
- Click Execute Script above the list. The Execute Script page is displayed.
- To execute more scripts, click Add Script. In the displayed Add Script dialog box, select the scripts to execute and click OK.
- If the selected script does not need to be executed, click Deselect in the Operation column on the Execute Script page.
- Select I've checked. No problem. and click Next: Select Target Object.
- In the Available Objects area, search for the desktop or desktop pool name, select the name, and click Select Execution Configuration.
- Select an execution policy, as shown in Table 1.
Table 1 Execution policies Policy Execution Mode
Parameter Description
Operation
Delivery to all
By default, the script is executed for all selected desktops or desktop pools.
- Set Execution Policy to Delivery to all.
- Set the script execution timeout, which ranges from 1 to 600 minutes.
Gray delivery
Specified: whether the desktop or desktop pool for which the script is to be executed belongs to the first batch of objects.
- If Execution Policy is set to Gray delivery, set Gray Rule to Specified.
- Toggle on the First-Batch Execution (Yes/No) switch and select a desktop.
NOTE:
First-batch execution is allowed only for running desktops whose login status is Disconnected, In use, or Ready.
- Set the script execution timeout, which ranges from 1 to 600 minutes.
- Enter the threshold for stopping executing the next batch if the number of desktops with script execution failure in the first batch is greater than or equal to x.
Random: The desktop or desktop pool for which the script is to be executed is randomly selected.
NOTE:The gray delivery policy divides desktops into the gray batch and non-gray batch. If the number of desktops with script execution failure in the first batch is greater than or equal to x, scripts will not be executed for desktops in the non-gray batch. If the threshold x is not reached, scripts will be executed for desktops in the non-gray batch.
- If Execution Policy is set to Gray delivery, set Gray Rule to Random.
- Set the script execution timeout, which ranges from 1 to 600 minutes.
- Enter the threshold (x) for the number of desktops that are randomly selected for script execution in the first batch.
- Enter the threshold for stopping executing the next batch if the number of desktops with script execution failure in the first batch is greater than or equal to x.
- If you want to perform this operation, enter YES or click Auto Enter. Click Execute.
You can choose Script Management > Desktop Script Records or Desktop Pool Script Records to view the script execution result.
Editing a script
- Click Edit in the Operation column of the desired script. The Edit Script page is displayed.
- You can edit the script name, description, and script content.
- Click OK.
Copying a script
- Click Copy in the Operation column of the desired script. The Copy Script page is displayed.
- You can edit the copied script name, execution environment, description, and script content.
- Click OK.
Deleting a script
- Click Delete in the Operation column of the desired script. The Delete Script page is displayed.
- Click OK.
Desktop or desktop pool script records
- Under the Desktop Script Records tab, you can use filters, such as Desktop ID, Script ID, Task ID, Execution Status, First-Batch Execution (Yes/No), and Started, to check data of the desktop, such as Desktop Name/ID, Script Name/ID, Task ID, Execution Status, First-Batch Execution (Yes/No), Response, Execution History, Started, and Ended.
- In the Script Name/ID column, click a script name to check History Script Details.
- In the Execution Status column, click Retry and click OK to execute the script again.
- In the Response column, click View to check the response of the desktop to the script execution. You can click Download to download the response.
- In the Execution History column, click View to view Execution Status, First-Batch Execution (Yes/No), Response, Started, and Ended of the script. Click Retry to execute the script again. Click View in the Response column to view the response, or click Download to download the response.
- Under the Desktop Pool Script Records tab, you can use filters, such as Desktop Pool ID, Script ID, Task ID, Execution Status, and Started, to check data of the desktop pool, such as Desktop Pool Name/ID, Script Name/ID, Task ID, Execution Status, Execution Details, Started, and Ended.
- In the Script Name/ID column, click a script name to check History Script Details.
- In the Execution Status column, click Retry and click OK to execute the script again.
- In the Execution Details column, click View to check data of the desktop pool, such as Desktop Name/ID, Script Name/ID, Task ID, Execution Status, First-Batch Execution (Yes/No), Response, Execution History, Started, and Ended.
- In the Response column, click View to check the response of the desktop to the script execution. You can click Download to download the response.
- In the Execution History column, click View to view Execution Status, First-Batch Execution (Yes/No), Response, Started, and Ended of the script. Click Retry to execute the script again. Click View in the Response column to view the response, or click Download to download the response.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot