> ## Documentation Index
> Fetch the complete documentation index at: https://mw-docs.middleware.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Kubernetes with MS Powershell

> Kubernetes Powershell Infra Agent - Setup & Installation Docs | Middleware

The following section walks you through installing the Infrastructure Agent (Infra Agent) with Microsoft Powershell scripts. This method provides you the ability to install the Infra Agent using `helm` instead of manifest files.

<Note> The following steps assume that you have already installed `kubectl` on your machine </Note>

# Prerequisites

<Steps>
  <Step title="Kubernetes Version">
    Kubernetes `v1.21` or above
  </Step>

  <Step title="Kubernetes Access">
    Access to Kubernetes cluster and client (i.e. [kubectl](https://kubernetes.io/docs/reference/kubectl/kubectl/))
  </Step>

  <Step title="CLI Tools">
    Install [bash](https://www.gnu.org/software/bash/), [curl](https://curl.se/) and [wget](https://www.gnu.org/software/wget/)
  </Step>
</Steps>

### Step 1: Open Powershell Terminal

Set the `MW_API_KEY` and `MW_TARGET` environment variables:

```Powershell Powershell theme={null}
$env:MW_API_KEY= '<your-mw-api-key>'

$env:MW_TARGET = '<your-mw-target>'
```

## Step 2: Install with Helm \[Optional]

You have the option to install the Infra Agent with `helm` instead of using manifest files.

Set the following environment variable to use `helm`:

<Note> Make sure [helm](https://helm.sh/docs/intro/install/) is already installed on your machine prior to adding the following environment variable. </Note>

```Powershell Powershell theme={null}
$env:MW_KUBE_AGENT_INSTALL_METHOD='helm'
```

### Step 3: Install Infra Agent

Download the [MW Kubernetes Install script](https://github.com/middleware-labs/install.middleware.io/blob/master/scripts/mw-kube-agent-install-powershell.ps1) and execute the following command:

```Powershell Powershell theme={null}
.\mw-kube-agent-install-powershell.ps1 
```

# Troubleshooting

<Warning>  Run only one Infra Agent DaemonSet per cluster per host. Multiple agents will cause unexpected behavior. </Warning>

Once the Infra Agent is installed on your cluster metrics should begin appearing in the Middleware application within a few minutes. If metrics do not appear, confirm that Kubernetes has access to the internet, either directly or through a proxy, and that only one Infra Agent is running per cluster.

# Uninstall

Download the [MW Kubernetes Uninstall script](https://github.com/middleware-labs/install.middleware.io/blob/master/scripts/mw-kube-agent-uninstall-powershell.ps1) and execute the following command:

```Powershell Powershell theme={null}
.\mw-kube-agent-uninstall-powershell.ps1 
```

<Note> Need assistance or want to learn more about Middleware? Contact us at support\[at]middleware.io. </Note>
