# Deploy Agent Smith with Microsoft Intune

Rewst has two methods for deploying Agent Smith using Microsoft Intune:

1. Use Win32 Packaging
2. Deploy via Intune PowerShell Scripts

{% hint style="info" %}
Win32 is the preferred Microsoft way of deployment. This method provides more granular installation and health feedback, plus the ability to uninstall if the deployment is unsuccessful. However, this method is more complicated and time consuming.\
\
The use of Intune platform scripts is much simpler, but yields a much less robust result. You'll be shown a yes/no response for if the script runs, which may or may not install the app successfully. \
\
Choose the deployment method that fits your level of comfort and experience.
{% endhint %}

## Prerequisites for deployment

* Intune licensing
* Properly configured Agent Smith environment
* Agent Smith PowerShell configuration script, generated via Rewst form

{% hint style="info" %}
Click on each of the methods to expand and view its instructions.
{% endhint %}

<details>

<summary>Method 1: Deploy via Win32 packaging</summary>

### Generate Agent Smith script

Follow the instructions under the **Provision agents** section of the [Agent Smith Configuration Guide](https://docs.rewst.help/documentation/agent-smith/agent-smith-configuration-overview#set-up-agent-smith) to generate the dynamic PowerShell configuration script. Your generated script will look something like this:

```powershell
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Set-ExecutionPolicy RemoteSigned
iwr ((irm {{ INSTALLER }}).assets|?{$_.name -eq \\\\"rewst_agent_config.win.exe\\\\"}|select -exp browser_download_url) -OutFile rewst_agent_config.win.exe
.\\\\\\\\rewst_agent_config.win.exe --config-url {{ ENGINE_URL }}/webhooks/custom/trigger/{{ trigger_id }}/{{ ORG.ATTRIBUTES.id }} --config-secret {{ CONFIG_SECRET }} --org-id {{ ORGID }}

```

<figure><img src="https://1835401289-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAQQ1EHVcEsGKBPVHmiav%2Fuploads%2FHWyQEHvoJFVUvG7t4zii%2Fimage%20(59).png?alt=media&#x26;token=31873dae-ddd5-4203-9647-66ca45216430" alt="" width="331"><figcaption></figcaption></figure>

### Package using IntuneWin package

1. Create a PowerShell Install Script - install.ps1

   1. Create a clean folder structure for your application. Your folder should contain:
      1. Installer files: .ps1 in this case
      2. Optional PowerShell detection script

   Example folder structure:

```
AgentSmith
├── source
│   ├── install.ps1
├── scripts
│   └── DetectionScript.ps1
└── output

```

2. Create install.ps1 using the provided install script mentioned earlier.
3. Save the provided install script as `install.ps1`.

### **Create the IntuneWin package**

Use Microsoft Win32 Content Prep Tool (IntuneWinAppUtil.exe) to complete the following.

1. Download IntuneWinAppUtil from [GitHub](https://github.com/microsoft/Microsoft-Win32-Content-Prep-Tool/releases).
2. Open a command prompt, either CMD or PowerShell.
3. Run the following command:

   * **c**: Source folder, which contains your installer files.
   * **s**: Powershell install script
   * **o**: Output directory for the .intunewin package.<br>

   ```
   IntuneWinAppUtil.exe -c "FOLDERLOCATION" -s "INSERTPOWERSHELLFILENAMEHERE" -o "OUTPUTFOLDER"
   ```

&#x20;       Example:

```
IntuneWinAppUtil.exe -c "C:\\AgentSmith\\source" -s "install.ps1" -o "C:\\AgentSmith\\output"
```

4. Upon completion, your .intunewin package will be generated in the specified output folder.<br>

   <figure><img src="https://1835401289-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAQQ1EHVcEsGKBPVHmiav%2Fuploads%2FTNewFvchLnmPg9n7CoPn%2Fimage%20(60).png?alt=media&#x26;token=24594149-be60-4ae5-9e4d-b77cbb954633" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1835401289-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAQQ1EHVcEsGKBPVHmiav%2Fuploads%2FTrmzv2jjM0Vc7Se8wtUe%2Fimage%20(61).png?alt=media&#x26;token=921e549b-c151-4a72-a664-921f7da3345f" alt=""><figcaption></figcaption></figure>

### **Use Microsoft Endpoint Manager to deploy**

1. Sign in to the [Microsoft Endpoint Manager Portal](https://endpoint.microsoft.com/).
2. Navigate to **Apps > Windows > + Add > Windows app (Win32)**.
3. Upload your .intunewin package (AgentSmithSetup.intunewin).
4. Fill out the Name, Description, and Publisher fields under the App information tab of the Add App menu.(The other fields are optional, you are welcome to fill them out if you’d like.)
5. Under the **Program** tab, paste the following into the relevant fields:

   1. **Install command -** replace install.ps1 with the name of the ps1 installer script you created earlier in the process:<br>

      ```
      powershell.exe -ExecutionPolicy Bypass -File install.ps1 
      ```
   2. **Uninstall command:** <br>

      ```
      powershell.exe -ExecutionPolicy Bypass -Command "Get-Service -Name 'AgentSmithService' -ErrorAction SilentlyContinue | Stop-Service -Force -ErrorAction SilentlyContinue; sc.exe delete 'AgentSmithService'"
      ```

   <figure><img src="https://1835401289-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAQQ1EHVcEsGKBPVHmiav%2Fuploads%2FGgYAANWkaGRObjste5uF%2FCleanShot%202025-04-10%20at%2001.41.47%402x.png?alt=media&#x26;token=45c9d1dc-f789-4a0d-9e67-fd9dac99c6c4" alt=""><figcaption></figcaption></figure>

   1. **Install behavior:** select **System**
6. Under the **Requirements** tab:
   1. Specify the **Minimum operating system** - Windows 10, Windows 11, etc.<br>

      <figure><img src="https://1835401289-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAQQ1EHVcEsGKBPVHmiav%2Fuploads%2FRgkD2uMhvFc0dDvfnONa%2FCleanShot%202025-04-10%20at%2001.07.50%402x.png?alt=media&#x26;token=7c854dbd-a8be-4c16-87fa-ac5cc8f52d28" alt=""><figcaption></figcaption></figure>
   2. Specify the **Operating system architecture** - 32-bit or 64-bit.<br>

<figure><img src="https://1835401289-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAQQ1EHVcEsGKBPVHmiav%2Fuploads%2FyqU8utspBIpSWzJGVzBz%2FCleanShot%202025-04-10%20at%2001.07.24%402x.png?alt=media&#x26;token=56fb32cd-1530-408f-9bf4-433697d60112" alt=""><figcaption></figcaption></figure>

7. Under the **Detection Rules** tab:
   1. Choose **Manually configure detection rules** from the drop-down selector.\
      ![](https://1835401289-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAQQ1EHVcEsGKBPVHmiav%2Fuploads%2FdYTIP14p1Ldg6pFoAmur%2FCleanShot%202025-04-14%20at%2015.11.53%402x.png?alt=media\&token=67131c31-80c1-4620-8f14-bac26bd6112c)
   2. Add a rule.\
      ![](https://1835401289-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAQQ1EHVcEsGKBPVHmiav%2Fuploads%2FkrpruSn8MTgUBF3R0fam%2FCleanShot%202025-04-14%20at%2015.12.20%402x.png?alt=media\&token=c2a2b4ef-f5c4-43e3-b206-0ddfe3c6747c)
   3. Set the **Rule type** to **File**.\
      ![](https://1835401289-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAQQ1EHVcEsGKBPVHmiav%2Fuploads%2Fp1q7TuQCuDOACLZYwi5i%2FCleanShot%202025-04-14%20at%2015.12.47%402x.png?alt=media\&token=d013e2ad-df76-493c-ad30-ff5a4e180e14)
   4. Set the **Path** to C:\Program Files\RewstRemoteAgent\\
   5. Set **File or folder** to `rewst_remote_agent_REPLACEWITHORGID.win.exe` after replacing the placeholder ORGID.
   6. Set the **Detection method** to **File or folder exists**.&#x20;
   7. Alternatively you can use a detection script such as the one provided in the [Immybot install guide. ](https://docs.rewst.help/documentation/agent-smith/deploying-agent-smith-with-immybot)\
      ![](https://1835401289-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAQQ1EHVcEsGKBPVHmiav%2Fuploads%2FbRtxz2hLEM7oKHWf1e7Z%2FCleanShot%202025-04-10%20at%2001.15.44.png?alt=media\&token=3ed4ad9b-29c9-4ca9-9e67-529e7ceccfc2)
8. No alterations to the **Dependencies** or **Supersedence** tabs are needed. Under the **Assignments** tab:
   1. Assign the application to required groups, be they users or devices.\
      ![](https://1835401289-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAQQ1EHVcEsGKBPVHmiav%2Fuploads%2FXHoAFksLbWfHbmEE7pJu%2FCleanShot%202025-04-10%20at%2001.17.35%402x.png?alt=media\&token=8e9c85c2-38b7-4f49-a70e-250e3205c0da)
   2. Once your group is selected, the defaults here will work, but feel free to modify the settings to your comfort level.<br>

      <figure><img src="https://1835401289-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAQQ1EHVcEsGKBPVHmiav%2Fuploads%2FDvRoEWApmpMNQFm9s1qE%2FCleanShot%202025-04-10%20at%2001.18.20%402x.png?alt=media&#x26;token=f6d70aa6-4ecc-41c0-8c05-c5bcd72d7aad" alt=""><figcaption></figcaption></figure>
9. Under the **Review and Create** tab:

   1. Confirm your settings.
   2. Click **Create**.

   <figure><img src="https://1835401289-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAQQ1EHVcEsGKBPVHmiav%2Fuploads%2FCga9BXw5wZd8tESIDyw2%2FCleanShot%202025-04-10%20at%2001.18.44%402x.png?alt=media&#x26;token=a98745ab-d603-4ca5-b240-e2a37b44fc33" alt=""><figcaption></figcaption></figure>

   <figure><img src="https://1835401289-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAQQ1EHVcEsGKBPVHmiav%2Fuploads%2FNcecZnoj1jmDDfKQtgXV%2FCleanShot%202025-04-10%20at%2001.20.10%402x.png?alt=media&#x26;token=c45b20fe-c304-4fb5-8d55-5ac35bf4661c" alt=""><figcaption></figcaption></figure>

### Additional considerations

* Deploy initially to a test group to verify the agent installs and detects correctly before wider distribution.
* Intune checkin times can be sporadic at times, app deployment times may take up to 48 hours.
* After clicking create, you’ll be brought to the App overview page where you can monitor deployment progress. Verify that the deployment completes.

</details>

<details>

<summary>Method 2: Deploy via Intune Platform scripts</summary>

### Generate Agent Smith script

Ensure that you have your PowerShell script from the **Provision agents** section of your [Agent Smith Configuration Guide](https://docs.rewst.help/documentation/agent-smith/agent-smith-configuration-overview). Use a text editor such as VS Code to take this copied PowerShell script and save it as a .ps1 file.

<figure><img src="https://1835401289-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAQQ1EHVcEsGKBPVHmiav%2Fuploads%2FSnI517XQQ7GhDfdFJFDy%2Fimage%20(62).png?alt=media&#x26;token=d0939d80-85c5-412e-b201-5d31b0ca021c" alt="" width="331"><figcaption></figcaption></figure>

### Configure Intune PowerShell Script

1. Navigate to **Devices > Scripts and remediations** in Intune.\
   ![](https://1835401289-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAQQ1EHVcEsGKBPVHmiav%2Fuploads%2FkQ9ugYXF4c0ksuivUYvx%2FCleanShot%202025-04-10%20at%2000.17.55%402x.png?alt=media\&token=c4c62e6b-74a0-49a3-a9e5-7ece0cea4076)
2. Click **Platform Scripts > Add > Windows 10** and later to upload your PowerShell script.\
   ![](https://1835401289-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAQQ1EHVcEsGKBPVHmiav%2Fuploads%2FK614W3AeuoqDaZ5spROk%2FCleanShot%202025-04-10%20at%2000.18.43%402x.png?alt=media\&token=538a5e81-2b4c-4bbc-8ce0-a7ac0ca10cfe)
3. Add the script in the screen that appears:
   1. Enter `Agent Smith` into the **Name** field under the **Basics** tab.
   2. Under the **Script settings** tab:

      1. If you are not signing your scripts, set Enforce script signature check is set to no. [Enforcing script signature check will require any scripts to be signed.](https://learn.microsoft.com/en-us/intune/intune-service/apps/intune-management-extension)

      <figure><img src="https://1835401289-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAQQ1EHVcEsGKBPVHmiav%2Fuploads%2FmG83EEsWDrMNfKMXgBI9%2FCleanShot%202025-04-10%20at%2000.19.07%402x.png?alt=media&#x26;token=8fe43847-670e-4359-b206-0ff9068bee60" alt=""><figcaption></figcaption></figure>

      <figure><img src="https://1835401289-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAQQ1EHVcEsGKBPVHmiav%2Fuploads%2FoMOJbD3zkSrsz78O0ATh%2FCleanShot%202025-04-10%20at%2000.20.30%402x.png?alt=media&#x26;token=a8e2366c-d061-4efe-8a2f-de26122e60b9" alt=""><figcaption></figcaption></figure>

### Deploy via Intune

1. Assign the script to your target device or user groups under the **Assignments** tab.\
   \
   ![](https://1835401289-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAQQ1EHVcEsGKBPVHmiav%2Fuploads%2FM5cjnCnpjhsjHXXQ5l1j%2FCleanShot%202025-04-10%20at%2000.21.20%402x.png?alt=media\&token=6f7110b0-8576-40b0-b5d0-535c965c365e)
2. Monitor deployment progress and status via the Intune portal.\
   ![](https://1835401289-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAQQ1EHVcEsGKBPVHmiav%2Fuploads%2FYtZNcejS8f3KAHOnGbfs%2FCleanShot%202025-04-10%20at%2000.21.30%402x.png?alt=media\&token=bba568d5-ecfe-44d5-9ea3-388cb9808361)

<figure><img src="https://1835401289-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAQQ1EHVcEsGKBPVHmiav%2Fuploads%2FApoxYSyrTClfCreJMkQh%2FCleanShot%202025-04-10%20at%2000.22.09%402x.png?alt=media&#x26;token=99a24006-3865-48b8-bd27-68e1b7287f89" alt="" width="375"><figcaption></figcaption></figure>

</details>

## Verification and troubleshooting

* Validate deployment success through Intune reports.
* Monitor device statuses in the Azure IoT Hub portal.
* Review logs at `C:\\ProgramData\\RewstRemoteAgent` for troubleshooting.
* Ensure communication with Azure IoT Hub is not blocked by firewalls or endpoint protection software.

For additional support, refer to the [Agent Smith Troubleshooting Guide](https://docs.rewst.help/documentation/agent-smith/agent-smith-configuration-overview#troubleshoot-agent-smith) or reach out via the Rewst Discord server in the #agent-smith channel.
