tencent cloud


Configuring Custom Data (Windows CVM)

Last updated: 2022-08-12 15:06:27


    When creating a CVM, you can configure an instance by specifying custom data. During the first launch of the CVM, the custom data will be passed into the CVM in text format and be executed. If you purchase multiple CVMs at a time, the custom data text will be executed on all CVMs during their first launch.

    This document describes an example in which a PowerShell script is passed during the first launch of a Windows CVM.

    Supports and Limits

    • Windows operating systems that support custom data include:
    • Windows Server 2019 IDC 64-bit Chinese/English version
    • Windows Server 2016 IDC 64-bit Chinese/English version
    • Windows Server 2012 R2 IDC 64-bit Chinese/English version
    • A command can be executed by passing text only when a CVM is launched for the first time.
    • Before Base64 encoding, the size of the custom data cannot exceed 16 KB.
    • Custom data is Base64 encoded and then passed. If you directly copy a non-Base64 script file, do not select “The entry is Base64-encoded text”.
    • During launch, executing specified tasks in custom data will increase the amount of time it takes to launch the CVM. We recommend that you wait for a few minutes, and after the tasks are completed, test whether the tasks have been successfully executed.
    • In this example, specify the Windows PowerShell script by using the PowerShell label, for example, the <powershell></powershell> label.


    Preparing text

    Prepare text based on your actual requirements:

    PowerShell script

    Use the PowerShell label to prepare a PowerShell script.
    For example, if you need to create a “tencentcloud.txt” file with the content of “Hello Tencent Cloud.” in the C drive (C:), use the PowerShell label to prepare the following content:

    "Hello Tencent Cloud." | Out-File  C:\tencentcloud.txt

    Base64 encoded script

    1. Run the following command to create a PowerShell script named “script_text.ps1”.

      vi script_text.ps1
    2. Press i to switch to the editing mode, refer to the following content, write it into the file, and save the “script_text.ps1” script.

      "Hello Tencent Cloud." | Out-File  C:\tencentcloud.txt
    3. Run the following command to perform the Base64 encoding operation on the “script_text.ps1” script.

      base64 script_text.ps1

    The following information is returned:


    Passing text

    We provide multiple methods to launch an instance, and here we introduce two of them. Choose a method according to your requirements:

    1. Refer to Creating an Instance to purchase an instance, and click Advanced settings in 2. Complete configuration.
    2. In Advanced settings, enter the text content you have prepared in the Custom data text box.
    1. Follow the prompts on the interface to complete CVM creation.

    Verifying custom data configuration

    1. Log in to your CVM.
    2. On the operating system interface, open the C drive (C:), and check whether the tencentcloud.txt text file exists.
      If the tencentcloud.txt text file exists, the configuration is successful, as shown in the following figure:

    Viewing execution logs

    You can view the C:\Program Files\Cloudbase Solutions\Cloudbase-Init\log\cloudbase-init.log file to get the execution logs of the script.

    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support