We manage our Apple computers through Microsoft's MDM Intune. Intune has the ability to run a script on a computer as the root user with no end-user interaction. I have this script set to run on all Apple machines:
#!/bin/sh
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -allowAccessFor -specifiedUsers -clientopts -setdirlogins -dirlogins yes
Upon running it, Intune returns the error:
Can't call method "print" on an undefined value at /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart line 695.
This is the code within kickstart it is referencing:
IO::File->new(">${TargetDisk}${RemoteManagementLaunchdFile}")->print("enabled");
Echo('MSG_ACTIVATED_REMOTE_MANAGEMENT');
If I copy the script to the machine and run it locally, the script completes what is intended to do (enable directory based authentication for ARD). This error is only thrown when pushed through Intune. I am not able to edit the source code for obvious reasons, but I don't see why the print error is occurring otherwise.