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

这里的技术是共享的

You are here

jamf policy -id 112 ,,是执行策略,,如何执行 Configuration Profile AG chatgpt 有大用 有大大用

jamf policy -id 112 ,,是执行策略,,如何执行 Configuration Profile   

这是个很关键的点,而且你现在的理解已经非常接近了 👍
我先给结论,再解释为什么 Jamf 里“没有”类似 jamf profile -id xxx 的命令


一、结论先行(记住这句话)

Jamf Configuration Profile 不能像 Policy 一样通过命令“执行”

👉 它只能通过 MDM 下发 / 安装 / 移除
👉 没有 jamf profile -id xxx 这种命令


二、为什么 jamf policy -id 112 能执行,而 Profile 不行?

1️⃣ Jamf Policy 本质

jamf policy 是:

  • 客户端主动请求 Jamf

  • 立即执行脚本 / pkg / 命令

sudo jamf policy -id 112


即时
可重复执行
是“动作”


2️⃣ Configuration Profile 的本质

Configuration Profile 是:

  • MDM 配置状态

  • 不是“脚本 / 动作”

  • Jamf → Apple APNs → macOS 推送

✔ 是“状态配置”
❌ 不是“执行一次的命令”

👉 所以 不能被 jamf binary 直接调用


三、那 Profile 是如何“被执行 / 生效”的?

正确说法应该是:

Profile 被“下发并安装”

触发方式只有这些 👇


四、等价于“执行 Profile”的 5 种方式(实战)

✅ 方式 1:修改 Profile(最常用)

只要你:

  • 打开 Configuration Profile

  • Save

📌 Jamf 会:

  • 重新推送 MDM

  • 设备立刻尝试安装

👉 这就是最常用的“强制生效”方法


✅ 方式 2:调整 Scope(加/删再加)

  • 从 Scope 中移除设备

  • 保存

  • 再加回

  • 保存

📌 等价于:

Remove Profile → Reinstall Profile



✅ 方式 3:设备端触发 MDM Check-in

在客户端执行:

sudo jamf manage


sudo jamf recon


📌 作用:

  • 向 Jamf 报到

  • Jamf 发现设备命中 Profile

  • 触发 MDM 下发

❗ 不是“执行 Profile”,而是触发检查


✅ 方式 4:Jamf Pro Web 控制台「Flush MDM Commands」

路径:

Computer → 管控设备 → Management → Flush MDM Commands


📌 强制 Jamf:

  • 立即重发所有待下发的 Profile


✅ 方式 5:删除再重装 Profile(终极)

设备端:

sudo profiles remove -identifier com.xxx.profile sudo jamf manage


或 Jamf 控制台:

  • Remove Profile

  • Re-scope


五、你 永远做不到 的事情(避免走弯路)

❌ 不能这样做:

jamf profile -id 112 jamf config -id 112 jamf mdm -id 112


❌ 不能像 Policy 那样:

  • 定时执行

  • 手动执行一次

因为:

Profile 不是任务,是状态


六、如果你“想要像 Policy 一样控制 Profile”,正确做法是?

✅ 推荐设计模式(企业里常用)

方案 A:Policy + Scope Profile

  1. Policy 触发(登录 / Self Service / 手动)

  2. Policy 脚本:

  • 把设备加入某个 Static Group

  • Configuration Profile Scope 到该 Group

  • 📌 效果:

    Policy → 间接“触发” Profile 下发


    方案 B:Policy 里直接写脚本(不推荐长期)

    • defaults write

    • networksetup

    • profiles install

    ⚠️ 问题:

    • 会被 MDM Profile 覆盖

    • 不持久


    七、一句话记忆版

    jamf policy 是“执行命令”
    Configuration Profile 是“声明状态”
    所以 Profile 只能被“下发/安装”,不能被“执行”。


    如果你愿意,可以直接告诉我:

    • 你这个 Profile 是干什么的(VPN / PPPC / 屏幕录制 / Wi-Fi?)

    • 你现在为什么想“手动执行它”

    我可以直接帮你设计一个 Policy + Profile 的最佳实现方案,不绕路。



    但是 Configuration Profile 有 在 self service 中设为可用

    对,你这个点说得完全对,而且非常关键 👍
    但这里面**“看起来能点 ≠ 真正像 Policy 那样执行”,Jamf 在这个地方很容易让人误解**。我给你把底层逻辑一次讲透。


    一、先给你一个“不会出错”的结论

    Configuration Profile 在 Self Service 里设为“可用”,
    并不是“执行 Profile”,而是:
    👉 允许用户“请求 Jamf 下发 / 安装这个 Profile”。

    也就是说:

    • 点一次 ≠ 执行一次

    • 点的是“安装 / 移除状态”


    二、Self Service 里的 Profile,本质上在干什么?

    对比一下你熟悉的东西:

    项目PolicyConfiguration Profile
    Self Service 点击立即执行脚本/安装包向 Jamf 请求安装该 Profile
    是否可多次执行否(已安装就没动作)
    本质动作(Action)状态(State)
    点完有没有输出通常没有
    生效方式本地立即执行MDM 下发后生效

    三、用户在 Self Service 点 Profile 后,实际发生的流程

    真实内部流程是这样 👇

    1️⃣ 用户在 Self Service 点击 Install / 安装

    2️⃣ Jamf Pro 标记:

    该设备 → 命中该 Configuration Profile


    3️⃣ Jamf 通过 MDM(APNs) 发送:

    InstallProfile Command


    4️⃣ macOS 接收并安装 Profile

    5️⃣ Profile 状态变为:

    Installed


    📌 如果已经是 Installed,再点是不会重新安装的


    四、为什么你感觉“点了但没反应 / 没生效”?

    这是 Self Service Profile 的 4 个典型坑


    ❌ 1️⃣ 已经安装了(最常见)

    • Profile 状态是 Installed

    • 再点不会重装

    👉 验证:

    profiles list



    ❌ 2️⃣ User-level Profile,但当前没触发登录

    • Self Service 是当前用户

    • Profile 是 User Level

    • 用户没重新登录

    👉 解决:

    • 注销 / 登录

    • 或改成 Computer Level(如果合理)


    ❌ 3️⃣ Profile 被设计为「可移除」

    Self Service 里其实是:

    • 第一次点:Install

    • 已安装时显示:Remove

    📌 很多人误以为是“再次执行”


    ❌ 4️⃣ APNs / MDM 队列有积压

    • Jamf 里显示 Pending

    • 设备端没收到

    👉 强制:

    sudo jamf manage


    sudo jamf recon



    五、Self Service Profile 和 Policy 的核心差异(一定要记住)

    Self Service 里的 Profile 是“开关”
    Policy 是“按钮”

    • Profile:

      • 开 → 安装

      • 关 → 移除

    • Policy:

      • 每点一次就执行一次


    六、如果你真的“想让 Profile 每次点都生效”,正确做法

    ✅ 推荐方案(企业标准做法)

    方案:Self Service Policy + Static Group + Profile

    流程:

    1️⃣ Self Service 里放一个 Policy

    2️⃣ Policy 脚本:

    jamf addGroup -group "Enable-VPN-Profile" -computer "$(scutil --get ComputerName)"


    或用 Jamf 内置:

    • Add computer to static group

    3️⃣ Configuration Profile:

    • Scope → Static Group Enable-VPN-Profile

    📌 效果:

    用户点 Policy
    → Jamf 修改 Scope
    → Profile 被重新下发

    ✔ 可控
    ✔ 可审计
    ✔ 行为清晰


    七、什么时候 适合 把 Profile 放到 Self Service?

    ✅ 非强制、用户可选的配置

    比如:

    • VPN

    • Wi-Fi(BYOD)

    • 可选证书

    • 可选限制策略

    ❌ 不适合的

    • PPPC

    • 屏幕录制

    • FileVault

    • 安全限制

    这些应该 强制下发,不给用户选择


    八、一句话“破除误解”

    Self Service 里的 Configuration Profile
    看起来像“执行”,
    实际只是“申请安装或移除 MDM 配置”。


    如果你愿意,可以直接告诉我:

    • 你这个 Profile 是 Computer 级还是 User 级

    • Self Service 点了之后 Jamf 里显示什么状态(Pending / Installed)

    • Profile 具体管的是 什么 Payload

    我可以直接帮你判断:
    👉 为什么“点了,但你感觉它没执行”


    Profile 被设计为「可移除」 在哪里可以被设计为可移除

    image.png

    这是个非常好的问题,而且很多人一直在这里找错地方
    我先给你一个不会误解的结论,再告诉你在哪设、在哪根本设不了


    一、先给结论(重点)

    Configuration Profile 本身,并没有一个叫「可移除 / 不可移除」的开关

    👉 你在 Jamf 里看到的「可移除」,
    本质是由「Profile 的 Scope + Self Service 设置 + 设备是否受监督」共同决定的结果

    也就是说:
    不是 Profile 内容里勾出来的。


    二、那“可移除”到底是在哪里控制的?(3 个地方)


    1️⃣ 【最关键】Scope → Self Service(你能“设计”的地方)

    路径(Jamf Pro):

    Configuration Profiles → 选中 Profile   → Scope     → Self Service

    这里有几个非常容易被忽略的选项 👇

    关键选项说明

    选项作用
    Make available in Self Service允许用户看到这个 Profile
    Allow removal(或 Remove 可见)决定用户是否能在 Self Service 里移除
    Display Name / Description仅显示用

    📌 只要在 Self Service 可见,且没有限制移除
    ➡️ 用户就能点 Remove

    👉 这就是你看到的“Profile 被设计为可移除”的唯一显式设计点


    2️⃣ 设备是否是「监督设备(Supervised / ADE)」(系统层限制)

    即使你 在 Self Service 里允许安装

    非监督设备(常见于 BYOD)

    • 用户始终可以移除 Profile

    • Jamf 无法完全阻止

    监督设备(ADE / DEP)

    • Jamf 可以强制

    • 用户不能手动删除

    📌 判断:

    profiles status -type enrollment

    看是否:

    Enrolled via DEP: Yes


    3️⃣ Profile Payload 类型(不是你能改的)

    有些 Payload 天生就不能移除或必须强制

    Payload特性
    PPPC / TCC强制,不建议 Self Service
    FileVault强制
    Restrictions强制
    Wi-Fi / VPN常常可移除

    📌 但注意:
    这不是一个“开关”,而是 macOS 的安全规则


    三、一个非常常见的误区(你大概率踩过)

    ❌ 在 Profile 内容里找「Allow removal」

    ✔ 正确位置在 Scope → Self Service

    Profile 的 Payload 编辑页面里:

    • ❌ 没有任何“可移除”的选项

    • ❌ 也没有 plist key 控制


    四、用户侧“可移除”表现在哪里?

    1️⃣ Self Service

    • 已安装 → 显示 Remove

    • 未安装 → 显示 Install

    2️⃣ 系统设置(非监督设备)

    系统设置 → 隐私与安全 → 描述文件

    用户可删除


    五、如果你想做到「用户不能移除」

    ✅ 正确做法

    1. 不要放进 Self Service

    2. Scope 到 Computer / Smart Group

    3. 使用 ADE / Supervised 设备

    ❌ 错误做法

    • 指望 Profile 里有“不可移除”勾选

    • 用脚本反复重装(治标不治本)


    六、一句话记忆版

    “Profile 可移除”不是 Profile 的属性,
    而是你在 Scope → Self Service + 设备监督状态共同决定的行为。


    如果你愿意,可以告诉我:

    • 你这个 Profile 是什么类型(VPN / PPPC / Wi-Fi?)

    • 设备是不是 ADE / 监督

    • 你现在是在 Self Service 里看到 Remove,还是系统设置里能删?

    我可以直接告诉你:
    👉 这个 Profile 能不能被“彻底锁死”,以及是否值得这么做。


    普通分类: