You can do so by checking for the existence of the launchd files in /etc:
[[ -f /etc/RemoteManagement.launchd ]] && echo 'enabled' || echo 'disabled'
or for screen sharing:
[[ -f /etc/com.apple.screensharing.agent.launchd ]] && echo 'enabled' || echo 'disabled'
sudo launchctl list com.apple.screensharing
which will succeed if it’s running, hence enabled.
sudo launchctl list com.apple.screensharing
which will succeed if it’s running, hence enabled.
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -allowAccessFor -allUsers -privs -all -clientopts -setmenuextra -menuextra yes
Starting...
Warning: macos 10.14 and later only allows control if Screen Sharing is enabled through System Preferences.
Activated Remote Management.
Set the client options.
Setting allow all users to YES.
Setting all users privileges to 1073742079.
Done.