欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

jamf create extends attributes scripts example jamf 创建 延伸功能属性 扩展属性 脚本 AG chatgpt 有大用 有大大用

Certainly! Here's an example of how you can create an extended attribute with a script in Jamf Pro.当然!以下示例说明了如何使用 Jamf Pro 中的脚本创建扩展属性。

Let's say you want to create an extended attribute to store the current battery level of a device. You can achieve this by using a script to gather the battery information and populate the extended attribute with this value.假设您要创建一个扩展属性来存储设备的当前电池电量。为此,可以使用脚本收集电池信息,并使用此值填充扩展属性。

  1. Log in to your Jamf Pro console and navigate to the "Devices" section.登录到 Jamf Pro 控制台并导航到“设备”部分。

  2. Select "Extension Attributes" and then click "New" to create a new extended attribute.选择“扩展属性”,然后单击“新建”以创建新的扩展属性。

  3. Fill in the necessary information, such as the display name ("Battery Level"), description, data type (e.g., Integer), input type, and display type for the attribute.填写必要的信息,例如属性的显示名称(“电池电量”)、描述、数据类型(例如整数)、输入类型和显示类型。

  4. Under the "Inventory Display" tab, you can select to display the attribute in the inventory information for devices.在“清单显示”选项卡下,您可以选择在设备的清单信息中显示该属性。

  5. Under the "Scripts" tab, create a new script. For example, the script may be a simple shell script to gather the battery level of a macOS device:在“脚本”选项卡下,创建一个新脚本。例如,该脚本可能是一个简单的 shell 脚本,用于收集 macOS 设备的电池电量:

bash

#!/bin/bash # Use the "ioreg" command to get the current battery level (in percentage) batteryLevel=$(ioreg -l | grep -i capacity | tr '\n' ' | ' | awk '{printf("%.2f%%\n", $10/$5 * 100)}') # Output the battery level echo "<result>${batteryLevel}</result>"

You can then upload this script or create a new one directly in the "Scripts" tab of the extended attribute configuration.然后,您可以上传此脚本或直接在扩展属性配置的“脚本”选项卡中创建新脚本。

  1. Save the extended attribute. 保存扩展属性。 

When the associated script is run on devices, it will gather the current battery level and populate the extended attribute with this value. This allows you to report on devices based on their battery levels, create smart groups, or use the information in other management tasks within Jamf Pro.当关联的脚本在设备上运行时,它将收集当前电池电量,并使用此值填充扩展属性。这允许您根据设备的电池电量报告设备,创建智能组,或在 Jamf Pro 中的其他管理任务中使用这些信息。

Note: The specifics of the script may vary based on the platform (macOS, iOS, etc.) and the information you want to gather.注意:脚本的细节可能因平台(macOS、iOS 等)和您要收集的信息而异。


普通分类: