I have a script which does a dscl lookup on the users home directory, creates a new folder, then populates a desktop alias that directs to this new folder. If I run the script manually, it functions as expected. When run via Self Service or policy, the folder is not created and essentially the script fails. If I set the script to run Once Per User, the script does not execute via policy trigger, and does not display in Self Service. If I set the policy to once per computer, the policy executes but the script does not function as expected. Here is the code, although i think it has to do with the way in which the JSS is handling the script.... Any help / thoughts would be appreciated:
--Set some values for reuse
set theUser to do shell script "whoami" --return lower case values
set theUserPath to do shell script "whoami | tr '[a-z]' '[A-Z]'"
set theFilePath to "/Volumes/" & theUserPath & "$/User_Profile/SanBox" as Unicode text
set serverAddress to do shell script "dscl . -read /Users/" & theUser & " SMBHome | awk '{print $2}' | tr '' '/'"
--display dialog theFilePath
tell application "Finder"
mount volume "smb:" & serverAddress
delay 2
do shell script "mkdir -p " & theFilePath
delay 2
set theFile to POSIX file theFilePath as text
set theAlias to make new alias file at POSIX file ("/Users/" & theUser & "/Desktop") to theFile
set the name of theAlias to "SanBox (Online)"
end tell