rtrouton / rtrouton_scripts

Scripts to share
MIT License
1.3k stars 489 forks source link

Jamf-Pro-Delete-All-Policies-In-Specified-Category.sh - Parser error #94

Closed Trikster-Online closed 2 years ago

Trikster-Online commented 2 years ago

When I run this script, I get the following error... I don't know enough about scripting to know how to fix...

-:1: parser error : Document is empty

rtrouton commented 2 years ago

What version of Jamf Pro are you using? The reason I'm asking is that if you're using 10.34.2 or earlier, which doesn't support using Bearer Tokens for Classic API authentication, set the NoBearerToken variable to the following value as shown below:

# NoBearerToken="yes"

By default, it is set to the following value:

# NoBearerToken=""
Trikster-Online commented 2 years ago

Here ya go! All I added to the script was the URL of my Jamf Cloud instance...changed nothing else.

VERSION 10.37.2-t1648851072

rtrouton commented 2 years ago

For the URL of your Jamf Pro instance, did you add this?

whatever.jamfcloud.com

Or this?

https://whatever.jamfcloud.com

The reason I'm asking is that it needs to be https://whatever.jamfcloud.com.

Trikster-Online commented 2 years ago

Yep, it's the full URL...https://crcyadayada:8443... We can do a Zoom if you want to see it in action.

rtrouton commented 2 years ago

No, thank you. Please try running an unaltered copy of my script, which should prompt you for the URL, the username of the Jamf Pro account you're using and the password.

Trikster-Online commented 2 years ago

Error persists.

Trikster-Online commented 2 years ago

I messed around with the URL by removing the port 8443 and got the following...

Please enter your Jamf Pro server URL : https://crcURL.edu
Please enter your Jamf Pro user account : Please enter the password for the account: Please see below for the list of categories available on https://crcURL.edu

(nothing displayed, this was where I initially got the parser error)

Please enter the name of the category: to be deleted

/Users/w0859768/Desktop/Scripts/RemovePolicies.sh: line 222: ((: == 0 : syntax error: operand expected (error token is "== 0 ") /Users/w0859768/Desktop/Scripts/RemovePolicies.sh: line 227: ((: > 0 : syntax error: operand expected (error token is "> 0 ") An unknown error occurred. Exiting.

rtrouton commented 2 years ago

It has to be the correct URL, including the port number if the port number is something other than 443.

I'm not able to replicate the errors you're seeing on my end, though it may be a permissions issue. Please try this:

  1. Create a local Jamf Pro user with the Administrator privilege set (see screenshot for details).
  2. Use that newly-created account's username and password when using the script.

Screen Shot 2022-04-19 at 5 18 39 PM

Trikster-Online commented 2 years ago

Now that is interesting. The account I was using is a local admin account. I created one just like it, and that one worked. Any idea what would make the other one not work?

rtrouton commented 2 years ago

I'll leave that part of the investigation to you. I'm glad to hear that it's now working for you.