I normally run this script when trying to log into multiple computers via Apple Remote Desktop:
osascript -e 'tell application "System Events"' -e 'keystroke "username"' -e 'keystroke tab'
-e 'delay 0.5' -e 'keystroke "password"' -e 'delay 0.5' -e 'keystroke return' -e 'keystroke return' -e 'keystroke return' -e 'keystroke return' -e 'end tell'
When I try to run this script on computers running Mojave I get the error:
execution error: System Events got an error: osascript is not allowed to send keystrokes. (1002)
The Mac receiving the commands probably needs a PPPC profile that whitelists
osascript to control System Events via AppleEvents, and accessibility (for the keystroke).
Yes I manage to get it working by doing the following
1. If you have a Restrictions Config Profile make sure Allow AirPlay, View Screen by Classroom, and Screen Sharing (macOS 10.14.4 or later, enrolled via a PreStage enrolment) is checked under the Functionality tab.
2. Create a PPPC
ARD Agent can be found in /System/Library/CoreServices/RemoteManagement/ARDAgent.app >Allow System Events and Accessibility
Script Editor > Allow Accessibility
The PPPC profile no longer works on newer macOS's starting with Catalina. You have to enable RDC with a management command in Jamf.