---
title: "The AppVeyor API and PowerShell: Getting Started"
description: "Learn how to marry Appveyor and PowerShell using the AppVeyor API token, a PowerShell script, and a little ingenuity in this tutorial!"
canonical: "https://adamtheautomator.com/appveyor-powershell/"
---

# The AppVeyor API and PowerShell: Getting Started

> Learn how to marry Appveyor and PowerShell using the AppVeyor API token, a PowerShell script, and a little ingenuity in this tutorial!

Source: https://adamtheautomator.com/appveyor-powershell/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![The AppVeyor API and PowerShell: Getting Started](https://adamtheautomator.com/wp-content/uploads/2019/07/5d238ae5c824b514689ea556.jpg)

# The AppVeyor API and PowerShell: Getting Started

[![](https://secure.gravatar.com/avatar/d0b9d42e21e5622713f8b693aa5c0f9244d5f7dd200ed29b8398f52dee5de337?s=192&d=mm&r=g)Adam Bertram](https://adamtheautomator.com/author/adam-bertram/)17 July 20194 min. read

Categories: [DevOps](/category/devops/)

Tags:[AppVeyor](/tag/appveyor/)[PowerShell](/tag/powershell/)[Sponsored](/tag/sponsored/)

Table of Contents

*   [AppVeyor API Versions](#appveyor-api-versions)
*   [Prerequisites](#prerequisites)
*   [Authenticating to the AppVeyor API with PowerShell](#authenticating-to-the-appveyor-api)
*   [Example PowerShell AppVeyor API Usage](#example-appveyor-api-usage)
*   [AppVeyor On-Prem](#appveyor-on-prem)
*   [Code](#code)
*   [Summary](#summary)

[AppVeyor](https://www.appveyor.com/), a continuous integration solution for Windows and Linux is a great tool to build automated CI/CD pipelines. Using its built-in REST API with both the cloud and on-prem version, an AppVeyor API token, and a little PowerShell, we can build some cool automation around this!

_This post is sponsored by AppVeyor. If you’re looking for a complete continuous integration platform capable of running both in the cloud and on-prem, I highly recommend [checking them out](https://ci.appveyor.com/signup)._

AppVeyor is a CI/CD tool that allows developers to build automated pipelines for their software. I’m a PowerShell developer and marrying AppVeyor with PowerShell, to me, is a no-brainer.

I recently had the opportunity to start managing AppVeyor with their API and so far, it’s been straightforward. In this article, I’m going to cover how to get started working the AppVeyor API and PowerShell.

## AppVeyor API Versions

As of 07/06/19, AppVeyor has two versions of their API in use _v1_ and _v2_. These two API versions can be differentiated by how you make API calls. You’ll see these differences below including some terminology you may see used in the documentation when referring to each API version.

| Version | Endpoint Suffix | Label |
| --- | --- | --- |
| 1 | /api/ | Classic/Account-Level |
| 2 | /api/account/<account-name>/ | N/A |

AppVeyor API Versions

Also, you’ll find that if you’re inspecting REST calls with Fiddler or similar HTTP inspection tool by navigating appveyor.com, you will see _v2_ references when the documentation is still _v1_. Watch out for this!

**_Related: [Wrangling REST APIs and JSON with PowerShell](https://adamtheautomator.com/powershell-json/)_**

## Prerequisites

To get started using PowerShell with AppVeyor, you’re going to need an [AppVeyor account](https://ci.appveyor.com/signup) (appveyor.com). I use the free account because all of my projects are public but they also offer a paid account for private GitHub repos.

Once you have an account, you’ll then need to [set up a project](https://www.appveyor.com/docs/build-configuration/) (appveyor.com) if you don’t have one already. In my case, I have everything in GitHub so that consists of creating an AppVeyor project that links to a GitHub repo.

## Authenticating to the AppVeyor API with PowerShell

Assuming you’ve got a project created, you now need to find your AppVeyor API token. You’ll find this by clicking in the upper-right corner of the page and then going to _My Profile._ Once there, click on _API keys_ on the left and then on the dropdown in the middle. This dropdown will display _All accounts_ and _<account-name>_.

The _All accounts_ options references the _v2_ API while the _<account-name>_ option references the _v1_ API. The _v2_ option has complete control over all accounts while the _v1_ option only has control over a single account.

I will be using the _v2_ Appveyor API token in this tutorial but if you’re concerned about ensuring the utmost security, it would probably be better to use the _v1_ API key.

Ensure that the dropdown is set to _All accounts_.

You’ll then see the API key represented as the _Bearer token_ as shown below_._ Copy that to your clipboard.

![AppVeyor v2 API Key](https://adamtheautomator.com/content/images/2019/07/appveyor-api-powershell---image-15.png)

AppVeyor v2 API Key

Next, you’ll need to drop down into your favorite PowerShell editor. I like to store all of the common variables I’ll be working with up top. Below, I have:

*   My AppVeyor account name (`$accountName`) which may be different depending on if you’re using a cloud environment or on-prem.
*   The `$apiUrl` which represents the API endpoint all calls will point to. You can see that I have both the cloud and on-prem tokens defined as they will be different depending on which platform you use.
*   The Appveyor API token is copied from above (`$authToken`) with separate references for cloud and on-prem usage.
*   A PowerShell hashtable with the appropriate keys and values to pass to the API (`$authHeaders`)

```powershell
## Cloud
# $cloudAccountName = 'adbertram'
# $apiUrl = "https://ci.appveyor.com/api/account/$cloudAccountName"
# $authToken = 'v2.XXXXXXXXXXX'
## On-prem
$onPremAccountName = 'AppVeyor'
$apiUrl = "http://localhost:8050/api/account/$onPremAccountName"
$authToken = 'v2.XXXXXXXXX'
$authHeaders = @{
    "Authorization" = "Bearer $authToken"
    "Content-type"  = "application/json"
}
```

> _Note that I’m using the v2 API key here thus using the v1 API URL. If you are using the v1 API key, the value for `$apiUrl` will be simply be [https://ci.appveyor.com/api](https://ci.appveyor.com/api)._

## Example PowerShell AppVeyor API Usage

Once you’ve got your token and all of your common variables set up, it’s time to query the API to see if we can get anything in return. I’ll use the [_Get Projects_ endpoint](https://www.appveyor.com/docs/api/projects-builds/#get-projects) (appveyor.com) as a test. This endpoint returns all of the projects you have set up in your AppVeyor account.

To make an API call, use the [`Invoke-RestMethod`](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-restmethod?view=powershell-6) (microsoft.com) PowerShell cmdlet. Since you’ve already built the headers above (`$authHeaders`), that’s already available. Next, you’ll need the URI to call.

Using `$apiUrl` above, you can concatenate that base URI with the appropriate endpoint in this case, `/projects`. This will give you the URI to query. And providing the headers hashtable just built will build a command reference to query all of the projects you have in your account.

```powershell
$getProjectsUri = "$apiUrl/projects"
Invoke-RestMethod -Uri $getProjectsUri -Headers $authHeaders
```

Below is an example output you will receive.

```powershell
projectId                                       : 584065
accountId                                       : 59292
accountName                                     : <account-name>
builds                                          : {}
name                                            : PSADSync
slug                                            : psadsync
repositoryType                                  : gitHub
repositoryScm                                   : git
repositoryName                                  : <account-name>/PSADSync
repositoryBranch                                : master
isPrivate                                       : False
isGitHubApp                                     : False
skipBranchesWithoutAppveyorYml                  : False
enableSecureVariablesInPullRequests             : False
enableSecureVariablesInPullRequestsFromSameRepo : False
enableDeploymentInPullRequests                  : False
saveBuildCacheInPullRequests                    : False
rollingBuilds                                   : False
rollingBuildsDoNotCancelRunningBuilds           : False
rollingBuildsOnlyForPullRequests                : False
alwaysBuildClosedPullRequests                   : False
tags                                            :
nuGetFeed                                       : @{nuGetFeedId=0; id=psjotform-9cwmf027es01; name=Project PSJotForm; accountId=0; publishingEnabled=False;
                                                  created=0001-01-01T00:00:00+00:00}
securityDescriptor                              : @{accessRightDefinitions=System.Object[]; roleAces=System.Object[]}
disablePushWebhooks                             : False
disablePullRequestWebhooks                      : False
created                                         : 2019-06-20T15:37:32.6192958+00:00
```

## AppVeyor On-Prem

On May 5th, 2019, [AppVeyor announced](https://www.appveyor.com/blog/2019/05/01/appveyor-server-available-for-download/) (appveyor.com) an on-prem version. You can [download](https://www.appveyor.com/on-premise/#download) (appveyor.com) it and take a look at the [Getting Started guide](https://www.appveyor.com/docs/server/) (appveyor.com) if you’re interested in getting it set up.

The download and set up was extremely easy mainly because it looks exactly like the cloud version. From the screenshot below, the only way you can tell this is from my on-prem installation is the URL

![AppVeyor On-prem Installation](https://adamtheautomator.com/content/images/2019/07/appveyor-api-powershell---image-16.png)

AppVeyor On-prem Installation

I played with the on-prem version a bit when I was learning the API and it is exactly the same too!

## Code

Here’s the complete script used in this post.

```powershell
## Cloud
# $cloudAccountName = 'adbertram'
# $apiUrl = "https://ci.appveyor.com/api/account/$cloudAccountName"
# $authToken = 'v2.XXXXXXXXX'
## On-prem
$onPremAccountName = 'AppVeyor'
$apiUrl = "http://localhost:8050/api/account/$onPremAccountName"
$authToken = 'v2.XXXXXXXXX'
$authHeaders = @{
    "Authorization" = "Bearer $authToken"
    "Content-type"  = "application/json"
}
$getProjectsUri = "$apiUrl/projects"
Invoke-RestMethod -Uri $getProjectsUri -Headers $authHeaders
```

## Summary

There are loads of other endpoints you can call to perform just about anything with the [AppVeyor REST API](https://www.appveyor.com/docs/api/) both via the cloud and on-prem.

Using the techniques you’ve seen here will give you all of the knowledge you need to get started building PowerShell to take advantage of all the AppVeyor CI platform has to offer.

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fappveyor-powershell%2F&text=The%20AppVeyor%20API%20and%20PowerShell%3A%20Getting%20Started)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fappveyor-powershell%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fappveyor-powershell%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2026/06/featured_image-20.png)

### [Deploy Enterprise PowerShell Modules Using Azure Artifacts](/deploy-enterprise-powershell-modules-using-azure/)

Build a private PowerShell repository using Azure Artifacts with automated CI/CD publishing, semantic versioning, code signing, and JEA integration for secure enterprise module distribution.

![](https://adamtheautomator.com/wp-content/uploads/2025/01/featured-image-5.webp)

### [Build a Scalable PowerShell Pester Testing Framework](/powershell-pester-testing-framework/)

Learn how to create a maintainable and organized Pester testing framework for PowerShell that scales with your needs. Perfect for large test suites.

![](https://adamtheautomator.com/wp-content/uploads/2021/10/How-to-Edit-Files-with-a-Real-PowerShell-Text-Editor.jpg)

### [How to Edit Files with a Real PowerShell Text Editor](/powershell-text-editor/)

Tired of switching between PowerShell and the text editor windows? Why not use a PowerShell text editor instead? Learn how in this step-by-step tutorial

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
