I know this is and old thread, but when using the new JAMF API (with PS
5.1) you need to build authentication headers manually: check this:
https://stackoverflow.com/questions/27951561/use-invoke-webrequest-with-a-username-and-password-for-basic-auth...