I find that /usr/bin/profiles renew -type enrollment executes successfully when run in Terminal but fails when invoked from a privileged helper tool installed using SMJobBless and AppleScript, which can not launch the "setup Assistant.app". Some error message as follow:
20:05:22.304125+0800 profiles CheckProfilesFetchRateLimit: checkTime = '<private>'; timer expired = NO
20:05:22.304147+0800 profiles CheckProfilesFetchRateLimit: Fetch operation happened too quickly - try again later
20:05:22.323395+0800 profiles [ERROR] [0:MCXToolsInterface] Assertion Failed. File: /AppleInternal/Library/BuildRoots/11aa8fb2-5f4b-11ee-bc7f-926038f30c31/Library/Caches/com.apple.xbs/Sources/MCXTools/ConfigProfiles/MCXToolsInterface/MCXToolsInterface.mm:621
20:05:22.324533+0800 cfprefsd [0x147e0aae0] invalidated after getting a no-senders notification - client is gone
20:05:22.326390+0800 authtrampoline [0x15ae041a0] invalidated on xpc_connection_cancel()
20:05:22.326415+0800 ocTest [0x600001327b10] invalidated on xpc_connection_cancel()
20:05:22.331935+0800 ocTest result: (null) error: {
NSAppleScriptErrorAppName = ocTest;
NSAppleScriptErrorBriefMessage = "Error: DEP enrollment failed: (null) ((null):0)";
NSAppleScriptErrorMessage = "Error: DEP enrollment failed: (null) ((null):0)";
NSAppleScriptErrorNumber = 1;
NSAppleScriptErrorRange = "NSRange: {0, 133}";
}
In macOS 14, a full-screen experience is displayed instead of asking the user to enroll. Does this have any influence?