ConfigMgr

VMware, Azure and Automation

Using PowerShell for Aria OPS API

8 juli 2025 Cloud Foundation Powershell Script VMware

In a previous article, I wrote about accessing the Aria OPS Chargeback API. In that article, I used Postman for testing the API calls. I also wrote that I would convert those Postman API calls into a Powershell script. So here goes…

The steps to generate a bill and to retrieve the information from that bill are the same:

  1. Log in and get a token
  2. Generate a bill
  3. Retrieve the information from that bill

Login and get a token

# Define API URL
$apiUrl = "https://$vrops/suite-api/api/auth/token/acquire"

# Define login credentials
$body = @{
    username = $username
    password = $password
    authSource = "WorkspaceONE" # For me this is WorkspaceONE
} | ConvertTo-Json

# Define HTTP headers
$headers = @{
    "Content-Type" = "application/json"
}

# Make the POST request to log in
$response = Invoke-RestMethod -Uri $apiUrl -Method Post -Headers $headers -Body $body

# Extract the token from the response
$token = $response.token

# Display the token
Write-Output "Token: $token"

# Optionally store the token for future requests
$authHeaders = @{
    "Authorization" = "OpsToken $token"
}

You now have a token that can be used in the subsequent API calls.

Generate a bill

# Define API URL
$apiUrl = "https://$vrops/suite-api/api/chargeback/bills"

# Define the JSON body as a PowerShell hashtable
$body = @{
    title            = "Test Bill Generation"
    description      = "Test Bill Generation"
    billingStartTime = 1665122400000
    billingEndTime   = 1666322044280
    resourceIds      = @("dfc2d007-be10-45c7-9fef-bd2f77b274ff")
    policyId         = "5e3d8255-1c5e-48dd-92c5-b7a687c3c898"
    timeZone         = "UTC"
} | ConvertTo-Json -Depth 3  # -Depth ensures nested objects/arrays are serialized properly

# Define HTTP headers
$headers = @{
    "Content-Type"  = "application/json"
    "Authorization" = "OpsToken $token"   # Replace with your actual token if required
}

# Make the POST request
$response = Invoke-RestMethod -Uri $apiUrl -Method Post -Headers $headers -Body $body

# Output the API response
Write-Output $response

Information about billingStartTime, billingEndTime, and both IDs can be found in the referenced article.

Get the bill

# Define API URL
$apiUrl = "https://$vrops/suite-api/api/chargeback/bills/$id"

# Define HTTP headers
$headers = @{
    "Content-Type"  = "application/json"
    "Authorization" = "OpsToken $token"   # Replace with your actual token if required
}

# Make the POST request
$response = Invoke-RestMethod -Uri $apiUrl -Method Get -Headers $headers

# Output the API response
Write-Output $response

Of course, you would need some additional code to retrieve some IDs and some code for reporting and other stuff. But you get the idea…

ariachargebackpowershellscriptvmware

SDDC Manager - this operation is not allowed

Recent Posts

  • Using PowerShell for Aria OPS API
  • SDDC Manager – this operation is not allowed
  • Quota warning deploying Cloud Director vApp
  • Using API for Aria OPS Chargeback
  • Unable to set reservation on Org VDC

Recent Comments

Geen reacties om te tonen.

Archives

  • juli 2025
  • mei 2025
  • april 2025
  • maart 2025
  • november 2024
  • oktober 2024
  • januari 2024
  • november 2023
  • oktober 2023
  • september 2023
  • juni 2023
  • mei 2023
  • april 2023
  • november 2022
  • maart 2021
  • februari 2021
  • januari 2021
  • november 2020
  • oktober 2020
  • september 2020
  • juli 2020
  • juni 2020
  • april 2020
  • maart 2020
  • februari 2020
  • oktober 2019
  • september 2019
  • juli 2019
  • juni 2019
  • mei 2019
  • maart 2019
  • februari 2019
  • januari 2019
  • december 2018
  • november 2018
  • april 2018
  • januari 2018
  • juli 2017
  • juni 2017
  • mei 2017

Categories

  • AnyLinq
  • Azure
  • Cloud Director
  • Cloud Foundation
  • ConfigMgr
  • DIY
  • HomeAssistant
  • Microsoft
  • PowerCli
  • Powershell
  • SCCM
  • Script
  • Solutions
  • System Center
  • Veeam
  • VMware
  • vRealize Automation
  • vRealize Orchestrator
Proudly powered by WordPress | Theme: Doo by ThemeVS.