Skip to content
English
  • There are no suggestions because the search field is empty.

Using PowerShell to Call the Orchestry API

In this article, learn how to use PowerShell to call the Orchestry API

Using PowerShell is a great way to interact with the Orchestry API for those comfortable with scripting.

PowerShell Sample Script for Provisioning

Use the working example below to get started.

NOTE: We are only able to provide limited support for PowerShell scripting, restricted to troubleshooting errors with the API itself.

Sample Script:

$TenantId="<Insert TenantID>"
$ClientId="<Insert ClientID>"
$Secret="<Insert Secret>"
 
$uri="https://login.microsoftonline.com/" + $TenantId + "/oauth2/v2.0/token"
 
$body=@{
               grant_type="client_credentials"
               client_id=$ClientId
               client_secret=$Secret
               scope="api://app.orchestry.com/6b88b0b8-c153-41e8-8aee-cac4c76740d3/.default"
}
 
$resp=Invoke-RestMethod -Method Post -Uri $uri -Body $body -ContentType "application/x-www-form-urlencoded"
 
Write-Host "Access Token: " $resp.access_token
 
$uri_orchestry="https://api.orchestry.com/v1/provisioning/templates"
 
$body_orchestry=@{
  templateId= 'b4d20713-8a93-452b-fba9-a5a9e2030ab1'
  requestUserId= '762eb960-7040-45e4-90ec-b9ee1b885019'
  name= 'Workspace Request ABC'
  description= 'check team creation based on API'
  permissionType= 'Private'
  base64LogoImage= ''
  showInDirectory= 'true'
  siteURL= 'Workspace_Request_ABC'
  classification= 'Highly Confidential'
  sensitivityLabelId= '2a1f2bdd-bebd-4814-b458-3e51f25572ea'
  owners=@('762eb960-7040-45e4-90ec-b9ee1b885019')
  members=@(
    '762eb960-7040-45e4-90ec-b9ee1b885019',
    '0ed137cd-3348-45a4-96dc-9c0787436711',
    '82ae5a98-a6dd-4d37-9b03-9d19b0edf1a9'
  )
}
 
$headers_orchestry=@{
               'Content-Type'='application/json'
               'Authorization'= "Bearer " + $resp.access_token
}
 
Write-Host "Header Orchestry : " $headers_orchestry.Authorization
 
Invoke-RestMethod -Method 'Get' -Uri $uri_orchestry -Headers $headers_orchestry