Product Documentation

Reference attachments in scripts

Important: The features in this topic have been deprecated and are no longer available in Smart Tools. This topic will be removed at a later time. For more information, see What’s New in Citrix Smart Tools.

You can reference attachments, such as text or image files, within your script. The script content and the attachments are stored on the machine where you deploy your script.

This topic provides an example for creating references to text and image files within a simple PowerShell (ps1) script. You can download sample files at the bottom of this topic.

Step 1: Create a sample text file

  1. Create a sample file clm.txt with the following content:

    Name = Citrix Smart Tools
    Company = Citrix
    Application = Web
    Users = All
  2. Save the file.

Step 2: Prepare an image file

Save an image file in .gif, .png, or .jpg format. In this example, an image file clm.png is used.

Step 3: Create a script

  1. From the menu bar, click Smart Build.
  2. Click New Script.
  3. Enter the name of the script as File reference.
  4. In Type (File Ext), enter ps1 and click Next.
  5. Enter the following PowerShell code in the script source editor and click Next. The sample script specified in this example performs the following actions:

    • Reads the content of the attached sample text file and display the content.
    • Copies the attached image file to a specified location of the machine where you deploy the script.

       #Define a variable to read and display the content of an attached text file
       $data = Get-Content clm.txt
       #Display the content of the attached text file
       #Copy the attached image file to a specified location of the machine
       Copy-Item clm.png C:\
  6. (Optional) On the Parameters page, define parameters as needed. This example does not use any parameters.
  7. On the Attachments page, click Upload files. Select the clm.txt file and click Open. The file is uploaded.
  8. Repeat Step 7 to upload the clm.png file.
  9. Click Finish.

Step 4: Deploy the script

  1. From the menu bar, click Smart Build.
  2. Point to the script and select Actions > Deploy.
  3. Provide a job name, select a machine, and click Next.
  4. Select Run Now and click Next.
  5. Review the parameters and click Next.
  6. Click Finish. The script job runs and a status notification is sent to your registered email address.

Step 5: View job details

  1. From the menu bar, click Smart Build.
  2. Move the pointer over the script and select Actions > View.
  3. Click View Jobs.
  4. Under Instances, click the job name.
  5. Under Runs, click the run instance. Step details appear.
  6. Click the Step Output tab. The step result displays the content of the text file (script attachment).

    Step Output tab of script job details with Result output highlighted

The following screenshot shows that the image file (script attachment) is copied to the specified location on the machine.

Windows File Explorer window with CLM image file highlighted

Reference attachments in scripts