Aidrop 11.3.1

SCHARLES
New Contributor II

Hello,

I'm trying to script to enable aidrop for but it doesn't work going through a policy.
Aidrop remains deactivated

#!/bin/bash defaults write com.apple.sharingd DiscoverableMode "Everyone"

Thanks for your help,

1 REPLY 1

Not applicable

Hey @SCHARLES you might be missing some syntax in that command, you should try adding the -string part, something like this

defaults write com.apple.sharingd DiscoverableMode -string "Everyone"

Another note, when you run this command from an MDM, like jamfPro, the script would run as root and would only be adjusting root's preference. You'd want to run this as the logged in user for it to work in its current form.

Try this as a script you'd execute when a user is logged in:

#!/bin/bash

# grabs the name of the logged in user
loggedinuser=$(stat -f%Su /dev/console)
# grabs the uid of the logged in user since it knows the username
loggedinuid=$(id -u "$loggedinuser")
# this will run a command as a user based on their UID 
/bin/launchctl asuser "$loggedinuid" sudo -iu "$loggedinuser" defaults write com.apple.sharingd DiscoverableMode -string "Everyone"

You can also look into the -currentHost switch for the defaults command. So the command would be similar if you did defaults -currentHost write com.apple.sharingd DiscoverableMode -string "Everyone" The man page says:

-currentHost Restricts preferences operations to the host the user is currently logged in on.

I suppose this command would be more of a system wide change, but you'd have to do some testing. I didn't test any of this, just hoping to give you some hints. Post back if you get it working and let us know. I wish I remembered who I grabbed that launchctl command from, but thanks to whomever that was.