Skip to main content
Solved

Executed Command result to new account username?

  • February 8, 2017
  • 2 replies
  • 9 views

Forum|alt.badge.img+2

Hi everyone, I'm loving the resources here but I can't seem to find anything on this.
Using a policy, is it possible to create a local user with a username taken from results of an executed command in the 'Files and Processes' section? I see in the logs that my command is working and giving me the result I want, but I can't figure out how to get the results useable in the 'Local Accounts' section.

Best answer by mm2270

While I don't think its possible to pass the results from Execute Command to another section of a policy, you should look at the jamf binary help page. You can create accounts using a jamf binary verb createAccount, so you'd be able to pass the variable to a jamf command.

For example, run jamf help createAccount to see the information on creating an account with the jamf binary.

I don't know what you're putting into the Execute Command field, but you can store that in a variable and string two or more commands together there. For example

username=$(your command goes here); /usr/local/bin/jamf createAccount -username "$username" -realname "Some Body" -admin

The above would take your command, store it as a variable called "username", then use that with the jamf binary to use it as the source for the shortname. Separating the 2 commands with a ; is how to string them together in the single Execute Command field.

Anything more complicated than the above I would look at using a full script instead of Execute Command.

2 replies

mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • 7886 replies
  • Answer
  • February 9, 2017

While I don't think its possible to pass the results from Execute Command to another section of a policy, you should look at the jamf binary help page. You can create accounts using a jamf binary verb createAccount, so you'd be able to pass the variable to a jamf command.

For example, run jamf help createAccount to see the information on creating an account with the jamf binary.

I don't know what you're putting into the Execute Command field, but you can store that in a variable and string two or more commands together there. For example

username=$(your command goes here); /usr/local/bin/jamf createAccount -username "$username" -realname "Some Body" -admin

The above would take your command, store it as a variable called "username", then use that with the jamf binary to use it as the source for the shortname. Separating the 2 commands with a ; is how to string them together in the single Execute Command field.

Anything more complicated than the above I would look at using a full script instead of Execute Command.


Forum|alt.badge.img+2
  • Author
  • New Contributor
  • 1 reply
  • February 9, 2017

Great work around. Thank you!