param( [Parameter(Mandatory)][string]$Hostname, [Parameter(Mandatory)][string]$TokenFile, [string]$Address, [string]$Endpoint = 'https://ddns.hosti.me/DNS-Endpoint/update' ) $ErrorActionPreference = 'Stop' if (([uri]$Endpoint).Scheme -ne 'https') { throw 'Use HTTPS.' } $token = (Get-Content -LiteralPath $TokenFile -Raw).Trim() $body = @{ hostname = $Hostname } if ($Address) { $body.ip = $Address } $response = Invoke-RestMethod -Uri $Endpoint -Method Post -Headers @{Authorization="Bearer $token"} -Body $body if ($response -notmatch '^(good|nochg) ') { throw "Update rejected: $response" } Write-Output $response