# Install packages with Chocolatey

> Use OneFuse Scripting to install packages with Chocolatey on Windows servers

---

Site [llms.txt](/llms.txt)

---

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.

<div class="alert alert-warning" role="alert">


The code provided in this walkthrough is a sample only. It should be thoroughly reviewed and tested before use in your environment.
</div>


**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](/docs/onefuse/configure/modules/scripting/), paste the following into the **Launch Command** field:

   ```powershell
   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).

      ```powershell
      Invoke-Command -ComputerName {{OneFuse_VmNic0.hostname}} -ScriptBlock {
          choco install openssh -y
      }
      ```

   1. Run commands directly on the target server. This requires OpenSSH to be installed and configured on the target server.

      ```powershell
      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](#resources) section.

## Resources

- [Chocolatey install](https://chocolatey.org/install)
- [Chocolatey packages](https://chocolatey.org/packages)
- [Microsoft Docs: Enable-PSRemoting](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/enable-psremoting?view=powershell-7.1)
- [Use a bastion host to execute PowerShell scripts](/docs/onefuse/configure/modules/scripting/bastion-host/)
