Script issue - PPPC issue - does not make sense ?

jameson
Contributor II

When Users enroll their Mac the following scripts prompt users to pick country

#!/bin/bash

# Create folder
/bin/mkdir -p /Library/Company
/bin/chmod -R 755 /Library/Company
serialNumber=$( ioreg -c IOPlatformExpertDevice -d 2 | awk -F" '/IOPlatformSerialNumber/{print $(NF-1)}' )

# Prompt for Country
countryValue=`/usr/bin/osascript <<EOT
tell application "System Events"
    with timeout of 9999 seconds
    activate
    set theCountry to {"IDMAC", "NLMAC", "JPMAC", "USMAC"}
    set selectedCountry to {choose from list theCountry with prompt "Select Country"}
    end timeout
end tell
EOT`

# Set ComputerName|LocalHostName|HostName
scutil --set ComputerName  "$countryValue-$serialNumber"
scutil --set LocalHostName  "$countryValue-$serialNumber"
scutil --set HostName  "$countryValue-$serialNumber"

exit 0

But if often does not appear in the enrollment process and in the logs it shows

cript result: 175:231: execution error: Not authorised to send Apple events to System Events. (-1743) scutil: invalid option -- C usage: scutil interactive access to the dynamic store. or: scutil --prefs [preference-file] interactive access to the [raw] stored preferences. or: scutil [-W] -r nodename or: scutil [-W] -r address or: scutil [-W] -r local-address remote-address check reachability of node, address, or address pair (-W to "watch"). or: scutil -w dynamic-store-key [ -t timeout ] -w wait for presense of dynamic store key -t time to wait for key or: scutil --get pref or: scutil --set pref [newval] or: scutil --get filename path key pref display (or set) the specified preference. Valid preferences include: ComputerName, LocalHostName, HostName newval New preference value to be set. If not specified, the new value will be read from standard input. or: scutil --dns show DNS configuration. or: scutil --proxy show "proxy" configuration. or: scutil --nwi show network information or: scutil --nc show VPN network configuration information. Use --nc help for full command list or: scutil --allow-new-interfaces [off|on] manage new interface creation with screen locked. or: scutil --error err# display a descriptive message for the given error code scutil: invalid option -- C usage: scutil interactive access to the dynamic store. or: scutil --prefs [preference-file] interactive access to the [raw] stored preferences. or: scutil [-W] -r nodename or: scutil [-W] -r address or: scutil [-W] -r local-address remote-address check reachability of node, address, or address pair (-W to "watch"). or: scutil -w dynamic-store-key [ -t timeout ] -w wait for presense of dynamic store key -t time to wait for key or: scutil --get pref or: scutil --set pref [newval] or: scutil --get filename path key pref display (or set) the specified preference. Valid preferences include: ComputerName, LocalHostName, HostName newval New preference value to be set. If not specified, the new value will be read from standard input. or: scutil --dns show DNS configuration. or: scutil --proxy show "proxy" configuration. or: scutil --nwi show network information or: scutil --nc show VPN network configuration information. Use --nc help for full command list or: scutil --allow-new-interfaces [off|on] manage new interface creation with screen locked. or: scutil --error err# display a descriptive message for the given error code scutil: invalid option -- C usage: scutil interactive access to the dynamic store. or: scutil --prefs [preference-file] interactive access to the [raw] stored preferences. or: scutil [-W] -r nodename or: scutil [-W] -r address or: scutil [-W] -r local-address remote-address check reachability of node, address, or address pair (-W to "watch"). or: scutil -w dynamic-store-key [ -t timeout ] -w wait for presense of dynamic store key -t time to wait for key or: scutil --get pref or: scutil --set pref [newval] or: scutil --get filename path key pref display (or set) the specified preference. Valid preferences include: ComputerName, LocalHostName, HostName newval New preference value to be set. If not specified, the new value will be read from standard input. or: scutil --dns show DNS configuration. or: scutil --proxy show "proxy" configuration. or: scutil --nwi show network information or: scutil --nc show VPN network configuration information. Use --nc help for full command list or: scutil --allow-new-interfaces [off|on] manage new interface creation with screen locked. or: scutil --error err# display a descriptive message for the given error code

The strange this is then afterwards if I run the policy in self service afterwards it works fine.

I have added the PPPC profile and it is loaded when the script runs in the enrollment. So it does not make sense that it works in self service but not during enrollment. On some macΒ΄s it actually works, while on other the pick country step is simply skipped with the above error log

0 REPLIES 0