I have tried this in Powershell and with PHP curl. In both cases the login authentication fails. the issue is the generation of the login token. When I disable tokens, there is no issue with login using script. However when login tokens are not disable, the login fails becasue of the token. See https://docs.moodle.org/dev/Login_token for generation of the login token. I have use these directions and the login still fails. Has anyone written code that can login to a Moodle site with a script (PHP or Powershell) that uses login tokens...One that works?