# Deploy Agent Smith with ImmyBot

{% hint style="info" %}
This was shared during a recent open mic: [Feb 2nd, 2024 - Inside the Eye of the Brainstrom](https://docs.rewst.help/updates/roc-open-mics/feb-2nd-2024-inside-the-eye-of-the-brainstrom).

**Thanks to Kewp member Logan for submitting this guide. ✨**
{% endhint %}

[Immybot](https://docs.rewst.help/documentation/integrations/integration-guides/immybot-integration-setup) is a powerful DSC platform that utilizes integrated agents to spawn an ephemeral agent. This agent is then capable of running scripts such as the ones provided in this directory while being fueled by Immy's amazing PS Functions.

If you've never used Immybot, note that  `Invoke-ImmyCommand` is essentially the same as `PSRemote`'s `Invoke-Command`.

## Setup

### High-level overview

1. Create the [`software`](#software) object in Immybot
   * Immybot uses software objects to interpret an application that should be deployed and how to do so.
   * The scripts [here](https://github.com/BezaluLLC/Project-Foghorn/tree/main/ImmyBot%20Integration) should be entered in the corresponding blank script fields
   * The PowerShell scripts handle:
     * Detection of the agent
     * Installation of the agent
     * Uninstallation of the agent
     * Dynamically acquiring the latest version of the agent
     * Comparing the existing version vs. the latest version and applying the desired state.
2. Create and assign a [`configuration task`](#configuration-task) to the software object.
   * Configuration tasks can run post-install/update/detection scripts typically intended for ensuring running compliance with your configured settings.
   * Configuration tasks also store parameters for the software object. This allows for using variables in every other script for the software object, even without scripts being set on the task.
3. Create and define a [`Deployment`](#deployment)
   * Deployments are where the magic happens- this is where you tell Immy where and if you want your software present.
   * Select **Agent Smith** for the software in question, and fill in the parameters

### Software

1. To set up a software in Immybot for Agent Smith, start in the left menu, then navigate to **Library > Software > New**.<br>

   <figure><img src="https://github.com/BezaluLLC/Project-Foghorn-agent/assets/2997336/ea8f749a-47cf-4a05-af40-c461a9a17839" alt=""><figcaption></figcaption></figure>
2. This will bring you to a setup page that asks for an installer. Go ahead and indicate `none` here.&#x20;

   <figure><img src="https://github.com/RewstApp/docs.rewst.help/assets/2997336/48ccca1a-dd66-49c1-b807-bd6ab0535666" alt=""><figcaption></figcaption></figure>
3. Next, it will ask for a software to add the version to. Select `Add version to new software`.&#x20;

   <figure><img src="https://github.com/RewstApp/docs.rewst.help/assets/2997336/6eceb9ff-bb22-410b-95b8-c3a40e2897e8" alt=""><figcaption></figcaption></figure>
4. After selecting `new software`, you should be on the actual setup page now. Enter a name, logo, and description for your agent
5. Begin loading the PowerShell scripts into each corresponding field.

   * The names of the scripts provided in this directory indicate where they should be used on this page.

   <div align="left"><figure><img src="https://github.com/BezaluLLC/Project-Foghorn-agent/assets/2997336/fb95e366-9315-4d20-8dbc-37e641aa58ab" alt=""><figcaption></figcaption></figure></div>

### Configuration task

You will also need to set up a `Configuration Task` in order to pass parameters into the script.\
The way Immy handles this is by loading said parameters into a `Configuration Task`, then filling in your parameters:

Once parameters are all set, set `Scripts` to `Use separate scripts` and disable the `Test`, `Get`, and `Set` scripts, as we do not need to do any post-install configuration.

### Deployment

Once the rest is completed, all you need to do is deploy! Fill in all parameters, select your targets, and you're done!  If you have any troubles, the people in the [#v-immybot](https://discord.com/channels/801971115013963818/882364989057433680) channel in the [MSPGeek discord](https://discord.gg/mspgeek) has a ton of brilliant people willing to help :)
