CreateMobileAccount using Self Service

raphhyyy
New Contributor III

hey all,

i'm trying to utilize: /System/Library/CoreServices/ManagedClient.app/Contents/Resources/createmobileaccount -n

to prompt the user for the said parameter "-n" by using Self Service.

Currently what i have is:

#!/bin/sh

un=`/usr/bin/osascript <<EOT
tell application "System Events"
    activate
    with timeout of 600 seconds
        set un to text returned of (display dialog "Please type in your mobile username" default answer "" with icon 2)
    end timeout
end tell
EOT`

/System/Library/CoreServices/ManagedClient.app/Contents/Resources/createmobileaccount -n "$un"

i've also tried to use a simple bash script to prompt via Terminal

#!/bin/bash
# Ask the user for login details
username=$(read -r -p "Enter your Mobile Account Username: ")

/System/Library/CoreServices/ManagedClient.app/Contents/Resources/createmobileaccount -n "$username"

but get the error: Enter your Username: test *user name "" was not found: 0 ((null))

1 REPLY 1

shaquir
Contributor III

Hi @raphhyyy

In your first script, the User's returned value is placed in the variable "$un". Not sure if it was an intentional omission, but you can set that variable "$un" to the end of the statement:

/System/Library/CoreServices/ManagedClient.app/Contents/Resources/createmobileaccount -n "$un"