Script Management
Scenario
On the console, the administrator can remotely run commands based on the created scripts to perform operations on cloud desktops.
By default, running a PowerShell script on Windows desktops is disabled. You need to run commands to enable the function of running a PowerShell script.
Method: Press Win + R on the cloud desktop, enter powershell, and press Enter. On the CLI, run the command Set-ExecutionPolicy RemoteSigned, press Enter, and select y.
Prerequisites
You have obtained the script.
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. The Create Script page is displayed.
- 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 be executed 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 Select Object. The Select Target Object page is displayed.
- 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.
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.
- 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.
- 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.
- Click Execute.
You can choose Script Management > Desktop Script Records or Desktop Pool Script Records to check 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 check 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 check the script. On the page displayed, click Download to download the response of the desktop to the script execution.
- 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 check 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 check the script. On the page displayed, click Download to download the response of the desktop to the script execution.
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