Converting "defaults write" scripts to configuration profiles?

DanJ_LRSFC
Contributor III

Is there a guide anywhere on how to convert "defaults write" scripts to configuration profiles, now that we can't run scripts on startup any more?

For example, this Sophos KB article says that to get the Mac to use the domain name instead of the computer name when reporting the username to Sophos Central, I need to type:

defaults write /Library/Preferences/com.sophos.mcs SMEMcsPreferDomainName -bool true; sudo launchctl stop com.sophos.configuration

Can this be converted to a configuration profile with a custom payload?

1 REPLY 1

pkleiber
Contributor

Hi @DanJ_LRSFC ,

the script above has two parts:
First part

defaults write /Library/Preferences/com.sophos.mcs SMEMcsPreferDomainName -bool true

Changes the variable

SMEMcsPreferDomainName

in an existing plist file to the value true. You could also do this with a configuration profile.

The second part stops an existing launch daemon

sudo launchctl stop com.sophos.configuration

 Stops the job. Opposite of start, and it's possible that the job will immediately restart if the job is configured to stay running.

I think you cannot create this with a configuration profile.
You could put those two lines from your KB article in a shell script, make a policy and let this policy run once per computer for example.