Script to log out of Messages.app on macOS 11 Big Sur
August 25, 2021 1:30 PM   Subscribe

I'm looking for a way to automate the mass sign out from Messages via Jamf.

I run a 1:1 tech program at a school. The students all have Macbook Airs (macOS 10.15 or 11) and manage them with Jamf. My users are non admins and the messages.app/ichat/iMessage is restricted. They are still permitted to sign in to iCloud, which results in signing into Messages (and notifications of incoming messages and attachments taking up space) but cannot sign out by themselves as the program is prevented from running by Computers -> "Restricted Software".

I’m looking for a way to mass sign them all out. This is the closest solution I’ve found but I can’t get working and my AppleScript-fu is poor. This is a similar effort but doesn't work in my testing.
posted by now i'm piste to Computers & Internet (3 answers total)
 
This works on my machine running 10.14:

tell application "Messages"
        set serviceItemList to every service
        repeat with n from 1 to length of serviceItemList
                set currentService to item n of serviceItemList
                if service type of currentService is iMessage then log out currentService
        end repeat
end tell
posted by mewsic at 5:38 AM on August 26, 2021


Response by poster: Thanks for trying mewsic. On line 5 I had to change "log out currentService" to "logout currentService" to get Script Editor to run. Not working in Big Sur, no 10.14 machines to test on.
posted by now i'm piste at 9:03 AM on August 26, 2021


"log out" is a command in the Messages V12.0 dictionary, so if it didn't compile under Big Sur, it probably means the terminology has changed. I recommend you study the scripting dictionary for the version of Messages you're trying to script. Scan the commands, as I did to write the above, and find out what they changed that command to. It should be reasonably obvious.

Also, if you can provide info on what actually happens when you run it, it might be easier to troubleshoot it.
posted by mewsic at 8:29 PM on August 26, 2021


« Older How to prioritize and take action when faced with...   |   How to handle a legal threat from a customer Newer »
This thread is closed to new comments.