---
title: "Kubernetes Agent with MS Powershell"
description: "Install the Middleware Kubernetes Agent using PowerShell with clear steps for monitoring your clusters efficiently."
section: "Agent Installation"
breadcrumb: "Containers > Kubernetes > MS PowerShell"
canonical: "https://docs.middleware.io/get-started/agent/kubernetes/kubernetes-ms-powershell"
---
# Kubernetes Agent with MS Powershell

In this section, we will walk you through how you can install the Kubernetes agent using the Microsoft PowerShell scripts. You have two installation methods to choose from. You can either go with Helm or manifest files. Along with additional troubleshooting steps, we intend to give you the easiest installation solution possible.

> **Note:** This guide assumes that you have already installed kubectl on your machine.

## Prerequisites

#### 1 Kubernetes version

You are required to have Kubernetes `version ≥ 1.21`, which can be verified using the following command:

```bash
    kubectl version
```

![Kubernetes Agent Config Argo CD](/images/v2/agents/kubernetes/k8s-ms-powershell.jpg)

#### 2 Kubernetes Access

`kubectl ≥ v1.17.0` configured against your target cluster, which can be verified with the following:

```bash
    kubectl version --client
```

#### 3 CLI Tools

Helm v3.5+ (if using Helm) or a shell with bash, curl, and wget installed.

## Installation

#### 1 Set Environment Variables

The first and the most important step is to set environment variables containing your API key and target, which will be later used by the installation script.

To do so, first open your terminal and execute the following command, changing the values of MW_API_KEY and MW_TARGET with your credentials:

```bash
    $env:MW_API_KEY="your-initial-token"

    $env:MW_TARGET = 'your-initial-uid'
```

#### 2 Set Environment Variable for Helm (Only needed if you want Helm installation)

> **Note:** Make sure you have installed Helm in your environment before proceeding.

If you want to use Helm to install the agent instead of batch files, then you need to setup an environment variable.

It is important to note that once you set this variable and execute the script, Helm will be used. If you want to revert, you need to unset the environment variable and reinstall the agent.

To set the environment variable, execute the following command:

```bash
  $env:MW_KUBE_AGENT_INSTALL_METHOD='helm'
```

#### 3 Install the Agent

In this step, we will download the script and execute it. You have two options to download the script. You can either [download the script manually from our GitHub repository](https://github.com/middleware-labs/install.middleware.io/blob/master/scripts/mw-kube-agent-install-powershell.ps1) or you can use the cURL command to download the script directly from your terminal.

To download the script via the cURL method, execute the following:

```bash
    curl -o mw-kube-agent-install-powershell.ps1  https://raw.githubusercontent.com/middleware-labs/install.middleware.io/refs/heads/master/scripts/mw-kube-agent-install-powershell.ps1
```

Finally, execute the following command to install the agent on your system:

```bash
    .\mw-kube-agent-install-powershell.ps1
```

## Troubleshooting: Running scripts is disabled on this system

When you execute the script to install the agent, the system might throw you an error message saying “File cannot be loaded because running scripts is disabled on this system”. While there are multiple ways you can solve this issue, it is not recommended to remove the barrier configured by your system for every script you encounter on the system. So the best option is to uplift the barrier just for selective scripts.

To solve this issue, you can change the execution policy, which will prompt for permission every time you execute a third-party script:

```bash
    Set-ExecutionPolicy RemoteSigned
```

![Kubernetes Agent Config Argo CD](/images/v2/agents/kubernetes/k8s-set-execution-policy.jpg)

## Uninstall

If you wish to remove the agent from your system, you first have to download the uninstallation script. The script can be downloaded from our [GitHub](https://github.com/middleware-labs/install.middleware.io/blob/master/scripts/mw-kube-agent-uninstall-powershell.ps1) or cURL.

To download the script via cURL, use the following:

```bash
    curl -o mw-kube-agent-uninstall-powershell.ps1 https://raw.githubusercontent.com/middleware-labs/install.middleware.io/refs/heads/master/scripts/mw-kube-agent-uninstall-powershell.ps1
```

Once downloaded, execute the script for removal:

```bash
    .\mw-kube-agent-uninstall-powershell.ps1
```

Need assistance or want to learn more about Middleware? Get in touch with us via our Contact Us page or join our Slack channel.
