Install packages with Chocolatey

Use OneFuse Scripting to install packages with Chocolatey on Windows servers

This article assumes that your Windows templates already have OpenSSH and Chocolatey installed. If using a bastion/jump server, the article assumes that OpenSSH, Chocolatey and WinRM are configured. This has only been tested on Windows 2016 and 2019, but may work on other versions of Windows with modification.

Goal: Provide a sample framework that can be modified based on environmental requirements.

Create a Scripting Policy in OneFuse

  1. In the OneFuse Scripting Module, paste the following into the Launch Command field:

    powershell -ExecutionPolicy Bypass -File {{ scriptName }}
    
  2. Paste one of the following scripts into the Script Template field.

    1. Use a bastion/jump host to run commands on the target server. This uses basic PowerShell remoting to the target server (assumes passthrough authorization).

      Invoke-Command -ComputerName {{OneFuse_VmNic0.hostname}} -ScriptBlock {
          choco install openssh -y
      }
      
    2. Run commands directly on the target server. This requires OpenSSH to be installed and configured on the target server.

      choco install jre8 adobereader -y
      

Add Scripting Policy to vRealize Automation Blueprint

  1. Go to your vRealize Automation instance.
  2. Open the blueprint you use for Scripting.
  3. Add the OneFuse_ScriptingPolicy_ComputeProvisionPostLate_001Choco property to your Scripting blueprint with the value 'OneFuse:Choco'.
  4. Once the property is added to your blueprint, you are ready to test your script. For more information, see the links in the Resources section.

Resources