PowerShell Script: Get an Access Token to Authenticate to Orchestrator

by Simon Sparks · 9 February 2026

https://learn.microsoft.com/en-us/dotnet/framework/install/how-to-determine-which-versions-are-installed

[System.String]$strUsername = "service-account-name";
[System.String]$strHostFQDN = "orchestrator.cloudbuildtools.com";

[System.String]$strAccessUri = "https://$strHostFQDN)/iaas/api/login"; 

[System.Collections.Hashtable]$objHashtable = @{"refreshToken" = $strRefreshToken }

[System.Management.Automation.PSObject]$objPSObjectRequest = New-Object -TypeName PSObject -Property $objHashtable

[System.String]$strJson = ConvertTo-Json -InputObject $objPSObjectRequest -Compress;

[System.Management.Automation.PSObject]$objPSObjectReturn = Invoke-RestMethod $strAccessUri -Method POST -ContentType "application/json" -Body $strJson -SkipCertificateCheck -SkipHeaderValidation;

[System.String]$strAccessToken = $objPSObjectReturn.tokenType + " " + $objPSObjectReturn.token

Discover more from Cloud Build Tools

Subscribe to get the latest posts sent to your email.

You may also like