Microsoft Remote Desktop 10 Bookmarks

khuong_lai
New Contributor II

Hi Guys,

I've been trying to add remote desktop bookmarks from https://soundmacguy.wordpress.com/2020/06/14/managing-microsoft-remote-desktop-10-bookmarks-with-han... and when i run the script i get this error below

 

Executing Policy Add Remote Desktop H&L
Running script msrd10-add-remotedesktop...
Script exit code: 132
Script result: User: staff is logged in...
Username specified, Creating bookmark for: sysnet Domain not specified, username will not be prefixed... Creating bookmark: H&L /Library/Application Support/JAMF/tmp/msrd10-add-remotedesktop: line 98: 7252 Illegal instruction: 4 sudo -u "${loggedInUser}" "${msrd}" --script bookmark write $(uuidgen) --hostname "${hostname}" --friendlyname "${friendlyname}" --resolution "${resolution}" --group "${group}" --username "${username}" ${extraArgs} 2> /dev/null

Error running script: return code was 132.

 

But if i run sudo jamf policy when i'm in Terminal on the computer the policy executes fine.  Anyone able to chime in and help me out?  Thanks!

3 REPLIES 3

junjishimazaki
Valued Contributor

Hi this is my script to add Microsoft RDP connections.

#!/bin/sh

#Pass argument in policy

hostaAdress=$4
friendlyName=$5

# get the cli executable
cli="/Applications/Microsoft Remote Desktop.app/Contents/MacOS/Microsoft Remote Desktop"

LOGPATH='/private/tmp'

# grab the logged in username
loggedInUser=`/bin/ls -l /dev/console | /usr/bin/awk '{ print $3 }'`

# global settings
myUUID=`uuidgen`

# variable settings
remoteappprogram="/Applications/Microsoft Remote Desktop.app "

# deploy the above variables
sudo -u $loggedInUser "$cli" --script bookmark write "$myUUID" --hostname "$hostAddress" \
--friendlyname "$friendlyName" \
--redirectprinters true \
--username "$loggedInUser"

exit 0

FrankB
New Contributor

Did you ever find a solution? I'm facing the same problem:

I'm trying to deploy some Microsoft Remote Desktop bookmarks for our users, which I'm fairly certain I did in the past without much hassle using the built in --script command:

 

 

...
sudo -u $loggedInUser /Applications/Microsoft\ Remote\ Desktop.app/Contents/MacOS/Microsoft\ Remote\ Desktop --script bookmark write...

 

 


It's working from Self Service and from doing sudo jamf policy in terminal. But once running on it's own (once per computer / recurring check in) it errors out with:

Error running script: return code was 133.

 

Crash Report from MRD in Console:

Application Specific Signatures:
Incoming message euid:502 does not match secinitd uid:0

 

502 is the uid of my user account and I can only assume 0 is root, which runs the script. So my guess is, it has something to do with Apples security.

My goal is updating existing bookmarks with a new url and some other settings, without user interaction - and later use it as part of a prestage enrollment.

Does anybody know of a way around this error?

FrankB
New Contributor

ah, looks like I fixed it after having a good read of https://scriptingosx.com/2020/08/running-a-command-as-another-user/ again and using:

launchctl asuser "$uid" sudo -u "$loggedInUser"....

 That does the trick and the policy runs successfully.