Hi,
I’ve got a script which authorises machines on our ZeroTier network via API.
This works… Sporadically.
The script (in one call) sets name, description and ticks the authorised box. Sometimes though, it won’t tick the box, but the other calls work
These are the relevant lines of code in the script (Powershell)
// Previous lines pull the api key, date, network ID, member ID etc
$action = "Auth" //testing purposes
if($action -eq "Auth"){
$action = "true"
$humanaction = "Authorised"
} else {
$action = "false"
$humanaction = "DeAuthorised"
}
$name = hostname
$desc = "'$humanaction NinjaOne $currentdate'"
$body = @{
"name"=$name;
"description"=$desc;
"config"=@{
"authorized"=$action;
};
}
$json = ConvertTo-Json $body
Invoke-RestMethod -Uri https://my.zerotier.com/api/network/$networkID/member/$memberID -Body $json -Headers $headers -Method POST
$action is either true or false (I’ve also tried True/False and 1/0) depending on whether the script is invoked as “auth” or “deauth”.
Interestingly, the docs show that it should return the authorisation state in lower case
but it’s returning it in Sentence case instead
So, couple of questions
- Do we have any idea why this doesn’t work (all the time)? I built the script, tested it, then I gave it to the rest of the team and they sometimes come to me and say it’s not working (but not every time)
- Does the documentation need updating to correct the upper/lower response?
- I’d expect if the body was invalid that it would make NO changes, but it’s successfully changing the name and description.