Git Product home page Git Product logo

jamf-recovery-lock's People

Contributors

jamesfkane avatar shbedev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

jamf-recovery-lock's Issues

get_mgmt_id only pulling first 2000 results

I noticed in my testing some computers were not getting the recovery lock set, when I was testing the filter, but some were. After some digging it looks like the JAMF API get for https://{instance_id}.jamfcloud.com:8443/api/preview/computers?page=0&size=100&pagesize=100&page-size={number_of_computers}&sort=name%3Aasc',
headers=headers in get_mgmt_id in computers.py only returns 2000 results. I tested by going to the API itself and downloading the resulting json. I was able to fix it by doing a second get and changing the initial page to 1 from 0 and that pulled in the final 1972 results for the 3972 computers my org has. I modified the code to do a second json file and then merged the two arrays and it will filter the ones it wasn't before. Thought you may not realize this.

Editing main.py and filtering for 1 computer

In the readme it says " Test the script by editing main.py and filtering for 1 computer, before running this on all computers"

I don't know much about python script but from what I understand I believe I need to make a change on the following line.

computers_id = get_arm64('filter=general.name=="jdoe-mbp"') # remove filter argument to get all computers

Would I just need to change 'jdoe-mbp' to one of our computer names?
Also is there any other change I need to make just to test on one machine?
When I want to run the change for all machines do I just remove ('filter=general.name=="jdoe-mbp"')?

Maybe the readme could be updated with this info

Thanks
Zubair

Getting errors when attempting to run this script

Hello,

I am getting this error when attempting to run this. Using python 3.11.2. Changed Jamf url in the error for privacy, it is the correct Jamf URL in Creds.py

`Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/urllib3/connection.py", line 174, in _new_conn
conn = connection.create_connection(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/urllib3/util/connection.py", line 72, in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/socket.py", line 962, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
socket.gaierror: [Errno 8] nodename nor servname provided, or not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/urllib3/connectionpool.py", line 703, in urlopen
httplib_response = self._make_request(
^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/urllib3/connectionpool.py", line 386, in _make_request
self._validate_conn(conn)
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/urllib3/connectionpool.py", line 1042, in _validate_conn
conn.connect()
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/urllib3/connection.py", line 358, in connect
self.sock = conn = self._new_conn()
^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/urllib3/connection.py", line 186, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x103116f10>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/requests/adapters.py", line 489, in send
resp = conn.urlopen(
^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/urllib3/connectionpool.py", line 787, in urlopen
retries = retries.increment(
^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/urllib3/util/retry.py", line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='https', port=443): Max retries exceeded with url: //myjamfurl:8443/api/v1/auth/token (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x103116f10>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/user/Downloads/recoverylock/jamf-recovery-lock/main.py", line 2, in
from computers import get_arm64, get_mgmt_id
File "/Users/user/Downloads/recoverylock/jamf-recovery-lock/computers.py", line 9, in
'Authorization': f'Bearer {get_token()}',
^^^^^^^^^^^
File "/Users/user/Downloads/recoverylock/jamf-recovery-lock/auth/bearer_auth.py", line 39, in get_token
return get_token_from_api()
^^^^^^^^^^^^^^^^^^^^
File "/Users/user/Downloads/recoverylock/jamf-recovery-lock/auth/bearer_auth.py", line 43, in get_token_from_api
token = request_token()
^^^^^^^^^^^^^^^
File "/Users/user/Downloads/recoverylock/jamf-recovery-lock/auth/bearer_auth.py", line 21, in request_token
response = requests.request("POST", f'https://{instance_id}/api/v1/auth/token', headers=headers)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/requests/api.py", line 59, in request
return session.request(method=method, url=url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/requests/sessions.py", line 587, in request
resp = self.send(prep, **send_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/requests/sessions.py", line 701, in send
r = adapter.send(request, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/requests/adapters.py", line 565, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='https', port=443): Max retries exceeded with url: //myjamfurl:8443/api/v1/auth/token (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x103116f10>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known'))`

Error when executing the script

I hope it's okay to ask here?

I did all in the readme file (configured the URL, created the user, wrote all in the auth file.
Then installed python3 + requests and launched a Command Prompt (Windows).
Last, I set the filter to one test machine (called "99").

cd to the Github directory (cloned with Github Desktop) and then executed the script (main.py).

Then I get this error:

C:\Users\darky\OneDrive\Desktop\GitHub\jamf-recovery-lock>python3 main.py
Traceback (most recent call last):
  File "C:\Users\darky\OneDrive\Desktop\GitHub\jamf-recovery-lock\main.py", line 2, in <module>
    from computers import get_arm64, get_mgmt_id
  File "C:\Users\darky\OneDrive\Desktop\GitHub\jamf-recovery-lock\computers.py", line 1, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'
cmd_Ro4uVySRR2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.