---
title: "How to use PowerShell with OP5 Monitor HTTP API"
description: "PowerShell can be used to send POST and GET requests to the OP5 Monitor HTTP API. This guide provides example scripts for creating hosts and retrieving monitored hosts using PowerShell."
url: "https://docs.itrsgroup.com/docs/faq/op5/360020054814-op5-monitor-how-to-use-powershell-with-op5-monitor-http-api/index.html"
---
## Version

This article was written for version 7.3.14 of OP5 Monitor or later.

Articles in the Community-Space are not supported by OP5 Support.

## Introduction

This how-to will guide you to invoke POST and GET requests to the OP5 API.

## POST request

This request will create a host over the API.

**create\_host.ps1**

```
$endpoint = "https://<url_to_op5>/api/config/host"$username = "<op5 username>"$password = "<op5 password>"$host = @{    "host_name" = "<hostname>"    "address" = "<ip of host>" }$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username,$password)))Invoke-RestMethod -Method Post -Uri "$endpoint" -Body (ConvertTo-Json $host) -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -ContentType "application/json"
```

## GET request

This request will retrieve all hosts monitored in OP5 over the API.

**get\_hosts.ps1**

```
$endpoint = "https://<url_to_op5>/api/config/host"$username = "<op5 username>"$password = "<op5 password>"$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username,$password)))Invoke-RestMethod -Method Get -Uri "$endpoint" -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}
```

Note:

The invidivual code blocks above are intended to be saved in files and then executed over powershell.


