#
# Create new client credentials
#
$apiToken = "xxxxx_b4306692-389c-4f4b-8c3c-50638ef07086" # Use token with 'clients-auth' scope
$apiUrl = "https://rport.example.com:443/api/v1/clients-auth"
$apiUser = "john"
$password = (-join ((48..57) + (97..122) | Get-Random -Count 14 | % {[char]$_}))
$client_id = $env:computername
$body = @{
id=$client_id
password=$password
}
$json = $body|ConvertTo-Json
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $apiUser,$apiToken)))
Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization = "Basic $base64AuthInfo"} -Method Post -Body $json -ContentType 'application/json'