欢迎各位兄弟 发布技术文章
这里的技术是共享的
https://www.rocketman.tech/post/simple-jamf-api-tutorial
gg "jamf api execute policies"
https://yourServer.jamfcloud.com/JSSResource/policies/id/233
Authorization:
Bearer eyJhbGciOiJIUzI1NiJ9.eyJhdXRoZW50aWNhdGVkLWFwcCI6IkdFTkVSSUMiLCJhdXRoZW50aWNhdGlvbi10eXBlIjoiTERBUCIsImdyb3VwcyI6W10sInN1YmplY3QtdHlwZSI6IkpTU19VU0VSX0lEIiwidG9rZW4tdXVpZCI6IjE4NmQ0Mzc1LTNmYTctNGYxYi04MmU4LTRmZjA1NDdmNTdhYiIsImxkYXAtc2VydmVyLWlkIjotMSwic3ViIjoiMTI1IiwiZXhwIjoxNjk1ODE0MTEwfQ.9jLYti61GP7lUqAahx5ZjwKrXuuqiSSqXa0GBASEgzU
https://yourServer.jamfcloud.com/JSSResource/policies/id/233
https://yourServer.jamfcloud.com/JSSResource/policies/233/execute
curl --location --request POST 'https://your-jamf-pro-instance.example.com/JSSResource/policies/123/execute' \
--header 'Authorization: Basic base64encodedCredentials'
<policy>
<general>
<execute>true</execute>
</general>
</policy>
https://developer.jamf.com/api-reference/jamf-pro/policies/trigger-a-policy
https://developer.jamf.com/jamf-pro/docs/jamf-pro-api-overview
https://developer.jamf.com/jamf-pro/docs/classic-api-authentication-changes
https://developer.jamf.com/jamf-pro/docs/jamf-pro-api-overview#jamf-pro-api-documentation
https://developer.jamf.com/jamf-pro/reference/classic-api
https://developer.jamf.com/jamf-pro/reference/get_v1-static-user-groups-id
https://developer.jamf.com/jamf-pro/reference/get_v1-static-user-groups
https://developer.jamf.com/jamf-pro/v10.42.0/reference/classic-api
https://developer.jamf.com/JSSResource/computers/id/2707 根据计算机的id 查找计算机的信息
https://developer.jamf.com/jamf-pro/v10.42.0/reference/findcomputersbymacaddress
根据 mac 地址查找信息
https://yourServer.jamfcloud.com/JSSResource/computers/macaddress/{macaddress}
https://yourServer.jamfcloud.com/JSSResource/computers/macaddress/11:22:33:44:55:66/subset/{subset}
https://developer.jamf.com/jamf-pro/reference/findcomputergroupsbyid #根据组id得到组中所有的所有的计算机
https://developer.jamf.com/jamf-pro/reference/updatecomputergroupbyid 从计算机组中增加一台或多台计算机 删除一台或多台计算机
https://developer.jamf.com/jamf-pro/v10.42.0/reference/computercommands 计算机命令
https://yourServer.jamfcloud.com/JSSResource/users #得到jamf的帐户信息,
https://yourServer.jamfcloud.com/uapi/v1/auth #可以看到jamf我的帐户信息,
https://developer.jamf.com/jamf-pro/reference/findpoliciesbyid
https://developer.jamf.com/jamf-pro/reference/updatepolicybyid
https://yourServer.jamfcloud.com/JSSResource/accounts/userid/125 #帐户信息
https://developer.jamf.com/jamf-pro/v10.42.0/reference/mobiledeviceenrollmentprofiles
https://developer.jamf.com/jamf-pro/v10.42.0/reference/findosxconfigurationprofiles
https://developer.jamf.com/jamf-pro/v10.42.0/reference/findcomputergroups
https://developer.jamf.com/jamf-pro/v11.0.0/reference/computers
https://developer.jamf.com/jamf-pro/v11.0.0/reference/findcomputersbyidsubset
jamf api policies scope add a computer
To add a computer to a Jamf policy's scope using the Jamf API, you can make a POST request to the following endpoint:
POST /JSSResource/policies/id/{policyID}/scope/computer/{computerID}
Replace {policyID}
with the ID of the policy you want to add the computer to, and {computerID}
with the ID of the computer you want to add.
Here is an example of how you can add a computer to a policy's scope using the Jamf API in Python:
python
import requests url = "https://your.jamf.pro.server:8443/JSSResource/policies/id/{policyID}/scope/computer/{computerID}" headers = { "Authorization": "Basic your_api_credentials_here", "Content-Type": "application/json" } response = requests.post(url, headers=headers) if response.status_code == 201: print("Computer successfully added to policy scope") else: print("Failed to add computer to policy scope. Error: {}".format(response.text))
Ensure that you replace your.jamf.pro.server
, {policyID}
, {computerID}
, and your_api_credentials_here
with the appropriate values for your environment.
This code snippet will send a POST request to add the specified computer to the scope of the chosen policy. If the request is successful, it will print a confirmation message. If there is an error, it will print out the error message returned by the API.
jamf api policies get scope all computer
To retrieve the scope of all computers assigned to a specific Jamf policy using the Jamf API, you can make a GET request to the following endpoint:
GET /JSSResource/policies/id/{policyID}/scope/computers
Replace {policyID}
with the ID of the policy for which you want to retrieve the scope information.
Here is an example in Python to get the scope of all computers assigned to a specific policy using the Jamf API:
python
import requests url = "https://your.jamf.pro.server:8443/JSSResource/policies/id/{policyID}/scope/computers" headers = { "Authorization": "Basic your_api_credentials_here" } response = requests.get(url, headers=headers) if response.status_code == 200: data = response.json()["computers"] for computer in data: print("Computer ID: {}, Name: {}".format(computer["id"], computer["name"])) else: print("Failed to retrieve computers assigned to policy. Error: {}".format(response.text))
Replace your.jamf.pro.server
, {policyID}
, and your_api_credentials_here
with the appropriate values for your environment.
This code snippet will send a GET request to retrieve the scope of all computers assigned to the specified policy. If the request is successful, it will print out the ID and name of each computer in the policy's scope. If there is an error, it will print out the error message returned by the API.