Posted on 02-08-2017 01:11 PM
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.
Solved! Go to Solution.
Posted on 02-08-2017 08:29 PM
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.
Posted on 02-08-2017 08:29 PM
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.
Posted on 02-09-2017 05:59 AM
Great work around. Thank you!